Skip to content

Commit

Permalink
compatible with:
Browse files Browse the repository at this point in the history
<div class="foo"
<div class"foo">
<div class=foo">
<div class="foo>
  • Loading branch information
yaniswang committed Mar 28, 2013
1 parent cfaddb0 commit f44a39f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 15 deletions.
2 changes: 1 addition & 1 deletion coverage.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/htmlhint.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "htmlhint",
"version": "0.9.1",
"version": "0.9.2",
"description": "A Static Code Analysis Tool for HTML",
"main": "./index",
"dependencies": {},
Expand Down
28 changes: 18 additions & 10 deletions src/htmlparser.js
Expand Up @@ -82,7 +82,9 @@ var HTMLParser = (function(undefined){
else{
if((tagName = match[4])){//标签开始
arrAttrs = [];
var attrs = match[5], attrMatch;
var attrs = match[5],
attrMatch,
attrMatchCount = 0;
while((attrMatch = regAttr.exec(attrs))){
var name = attrMatch[1],
quote = attrMatch[2] ? attrMatch[2] :
Expand All @@ -91,16 +93,22 @@ var HTMLParser = (function(undefined){
attrMatch[5] ? attrMatch[5] :
attrMatch[6] ? attrMatch[6] : '';
arrAttrs.push({'name': name, 'value': value, 'quote': quote, 'index': attrMatch.index, 'raw': attrMatch[0]});
attrMatchCount += attrMatch[0].length;
}
saveBlock('tagstart', match[0], matchIndex, {
'tagName': tagName,
'attrs': arrAttrs,
'close': match[6]
});
if(mapCdataTags[tagName]){
tagCDATA = tagName;
arrCDATA = [];
lastCDATAIndex = lastIndex;
if(attrMatchCount === attrs.length){
saveBlock('tagstart', match[0], matchIndex, {
'tagName': tagName,
'attrs': arrAttrs,
'close': match[6]
});
if(mapCdataTags[tagName]){
tagCDATA = tagName;
arrCDATA = [];
lastCDATAIndex = lastIndex;
}
}
else{//如果出现漏匹配,则把当前内容匹配为text
saveBlock('text', match[0], matchIndex);
}
}
else if(match[2] || match[3]){//注释标签
Expand Down

0 comments on commit f44a39f

Please sign in to comment.