File tree 2 files changed +17
-3
lines changed
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;
2
2
3
3
// create optimized lookup object for
4
- // void elements as listed here:
4
+ // void elements as listed here:
5
5
// http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
6
6
var lookup = ( Object . create ) ? Object . create ( null ) : { } ;
7
7
lookup . area = true ;
@@ -42,7 +42,7 @@ module.exports = function (tag) {
42
42
}
43
43
res . name = match ;
44
44
} else {
45
- res . attrs [ key ] = match . replace ( / [ ' " ] / g, '' ) ;
45
+ res . attrs [ key ] = match . replace ( / ^ [ ' " ] | [ ' " ] $ / g, '' ) ;
46
46
}
47
47
}
48
48
i ++ ;
Original file line number Diff line number Diff line change @@ -53,5 +53,19 @@ test('parseTag', function (t) {
53
53
children : [ ]
54
54
} ) ;
55
55
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
+
56
70
t . end ( ) ;
57
71
} ) ;
You can’t perform that action at this time.
0 commit comments