4
4
*/
5
5
var Parser = require ( "fastparse" ) ;
6
6
7
+ var processMatch = function ( match , strUntilValue , name , value , index ) {
8
+ if ( ! this . isRelevantTagAttr ( this . currentTag , name ) ) return ;
9
+ this . results . push ( {
10
+ start : index + strUntilValue . length ,
11
+ length : value . length ,
12
+ value : value
13
+ } ) ;
14
+ } ;
15
+
7
16
var parser = new Parser ( {
8
17
outside : {
9
18
"<!--.*?-->" : true ,
@@ -18,22 +27,9 @@ var parser = new Parser({
18
27
inside : {
19
28
"\\s+" : true , // eat up whitespace
20
29
">" : "outside" , // end of attributes
21
- "(([a-zA-Z\\-]+)\\s*=\\s*\")([^\"]*)\"" : function ( match , strUntilValue , name , value , index ) {
22
- if ( ! this . isRelevantTagAttr ( this . currentTag , name ) ) return ;
23
- this . results . push ( {
24
- start : index + strUntilValue . length ,
25
- length : value . length ,
26
- value : value
27
- } ) ;
28
- } ,
29
- "(([a-zA-Z\\-]+)\\s*=\\s*)([^\\s>]+)" : function ( match , strUntilValue , name , value , index ) {
30
- if ( ! this . isRelevantTagAttr ( this . currentTag , name ) ) return ;
31
- this . results . push ( {
32
- start : index + strUntilValue . length ,
33
- length : value . length ,
34
- value : value
35
- } ) ;
36
- }
30
+ "(([a-zA-Z\\-]+)\\s*=\\s*\")([^\"]*)\"" : processMatch ,
31
+ "(([a-zA-Z\\-]+)\\s*=\\s*\')([^\']*)\'" : processMatch ,
32
+ "(([a-zA-Z\\-]+)\\s*=\\s*)([^\\s>]+)" : processMatch
37
33
}
38
34
} ) ;
39
35
0 commit comments