Skip to content

Commit

Permalink
fix attribute with no value
Browse files Browse the repository at this point in the history
  • Loading branch information
deanmao committed May 4, 2012
1 parent 2267f32 commit fdcdd0a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions lib/htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ function Parser (builder, options) {
}
state.pos += name_data.match.length;
var value_data = this._parseAttr_findValue(state);
var end = state.data.indexOf(' ', state.pos);
if (value_data) {
if (!state.done && state.pos + value_data.match.length === state.data.length) {
state.needData = true;
Expand All @@ -357,16 +358,24 @@ function Parser (builder, options) {
}
state.pos += value_data.match.length;
} else {
Parser.re_parseAttr_splitValue.lastIndex = state.pos;
if (Parser.re_parseAttr_splitValue.exec(state.data)) {
state.needData = true;
state.pos -= name_data.match.length;
return;
if (state.data.indexOf(' ', state.pos-1)) {
value_data = {
match: ''
, value: name_data.name
};

} else {
Parser.re_parseAttr_splitValue.lastIndex = state.pos;
if (Parser.re_parseAttr_splitValue.exec(state.data)) {
state.needData = true;
state.pos -= name_data.match.length;
return;
}
value_data = {
match: ''
, value: null
};
}
value_data = {
match: ''
, value: null
};
}
state.lastTag.raw += name_data.match + value_data.match;

Expand Down

0 comments on commit fdcdd0a

Please sign in to comment.