Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix attribute with no value

  • Loading branch information...
commit fdcdd0a3f421e7ca28aa10816b79e5d78b1cfba8 1 parent 2267f32
@deanmao authored
Showing with 18 additions and 9 deletions.
  1. +18 −9 lib/htmlparser.js
View
27 lib/htmlparser.js
@@ -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;
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.