File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1- var attrRE = / ( [ \w - ] + ) | [ ' " ] { 1 } ( [ ^ ' " ] * ) [ ' " ] { 1 } / g;
1+ var attrRE = / ( [ \w - ] + ) | ( [ ' " ] ) ( . * ? ) \2 / g;
22
33// create optimized lookup object for
4- // void elements as listed here:
4+ // void elements as listed here:
55// http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
66var lookup = ( Object . create ) ? Object . create ( null ) : { } ;
77lookup . area = true ;
@@ -42,7 +42,7 @@ module.exports = function (tag) {
4242 }
4343 res . name = match ;
4444 } else {
45- res . attrs [ key ] = match . replace ( / [ ' " ] / g, '' ) ;
45+ res . attrs [ key ] = match . replace ( / ^ [ ' " ] | [ ' " ] $ / g, '' ) ;
4646 }
4747 }
4848 i ++ ;
Original file line number Diff line number Diff line change @@ -53,5 +53,19 @@ test('parseTag', function (t) {
5353 children : [ ]
5454 } ) ;
5555
56+ tag = '<div class="button another-button" onclick="do(\'something\');" onhover=\'do("something else")\'>' ;
57+
58+ t . deepEqual ( parseTag ( tag ) , {
59+ type : 'tag' ,
60+ attrs : {
61+ class : 'button another-button' ,
62+ onclick : 'do(\'something\');' ,
63+ onhover : 'do("something else")'
64+ } ,
65+ name : 'div' ,
66+ voidElement : false ,
67+ children : [ ]
68+ } ) ;
69+
5670 t . end ( ) ;
5771} ) ;
You can’t perform that action at this time.
0 commit comments