From ab819705fe96960374e9e3fe24f0677977286190 Mon Sep 17 00:00:00 2001 From: Duncan Beevers Date: Sat, 26 Jul 2014 16:10:03 -0500 Subject: [PATCH] Splay out attribute recognizer --- src/htmlparser.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/htmlparser.js b/src/htmlparser.js index 35435fd..70895b4 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -37,7 +37,13 @@ startTagClose = /\s*(\/?)>/, endTag = /^<\/([\w:-]+)[^>]*>/, endingSlash = /\/>$/, - singleAttr = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/, + singleAttrIdentifier = /([\w:-]+)/, + singleAttrAssign = /=/, + singleAttrValues = [ + /"((?:\\.|[^"])*)"/.source, // attr value double quotes + /'((?:\\.|[^'])*)'/.source, // attr value, single quotes + /([^>\s]+)/.source // attr value, no quotes + ], doctype = /^]+>/i, startIgnore = /<(%|\?)/, endIgnore = /(%|\?)>/; @@ -92,6 +98,17 @@ } function attrForHandler( handler ) { + var singleAttr = new RegExp( + singleAttrIdentifier.source + + '(?:\\s*' + + singleAttrAssign.source + + '\\s*' + + '(?:' + + singleAttrValues.join('|') + + ')' + + ')?' + ); + if ( handler.customAttrSurround ) { var attrClauses = []; for ( var i = handler.customAttrSurround.length - 1; i >= 0; i-- ) { -- 2.34.1