@@ -28,6 +28,10 @@ class WXMLParser {
28
28
return this . inputs [ this . pos ] ;
29
29
}
30
30
31
+ getNextString ( len ) {
32
+ return this . inputs . substr ( this . pos , len )
33
+ }
34
+
31
35
startWiths ( str ) {
32
36
return this . inputs . substr ( this . pos , str . length ) === str ;
33
37
}
@@ -42,9 +46,18 @@ class WXMLParser {
42
46
return this . inputs [ this . pos ++ ] ;
43
47
}
44
48
45
- consumeWhile ( matchFunc ) {
49
+ consumeCharIgnoreWhitespace ( ) {
50
+ const text = this . consumeWhitespace ( )
51
+ // if (text) {
52
+ // handlerCompany.call(this, 'text', text);
53
+ // }
54
+ return this . inputs [ this . pos ++ ] ;
55
+ }
56
+
57
+ consumeWhile ( matchFunc , len ) {
46
58
let result = '' ;
47
- while ( ! this . isEOF ( ) && matchFunc ( this . getNextChar ( ) ) ) {
59
+
60
+ while ( ! this . isEOF ( ) && matchFunc ( len ? this . getNextString ( len ) : this . getNextChar ( ) ) ) {
48
61
result += this . consumeChar ( ) ;
49
62
}
50
63
return result ;
@@ -129,17 +142,17 @@ class WXMLParser {
129
142
}
130
143
131
144
if ( tagName === 'wxs' ) {
132
- const wxs = this . consumeWhile ( char => char !== '<' ) ;
145
+ const wxs = this . consumeWhile ( str => str !== '</wxs' , 5 ) ;
133
146
handlerCompany . call ( this , 'wxs' , wxs ) ;
134
147
} else {
135
148
this . parseNodes ( ) ;
136
149
}
137
150
138
- assert . ok ( this . consumeChar ( ) === '<' ) ;
139
- assert . ok ( this . consumeChar ( ) === '/' ) ;
151
+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '<' ) ;
152
+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '/' ) ;
140
153
let closeTagName = this . parseTagName ( ) ;
141
154
handlerCompany . call ( this , 'closetag' , closeTagName , false ) ;
142
- assert . ok ( this . consumeChar ( ) === '>' ) ;
155
+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '>' ) ;
143
156
}
144
157
145
158
parseTagName ( ) {
@@ -216,7 +229,6 @@ let minifier = function(source, options) {
216
229
str += `</${ tagname } >` ;
217
230
} ,
218
231
onwxs ( wxs ) {
219
- console . log ( wxs ) ;
220
232
str += wxs ;
221
233
}
222
234
} ) ;
0 commit comments