@@ -28,6 +28,10 @@ class WXMLParser {
2828 return this . inputs [ this . pos ] ;
2929 }
3030
31+ getNextString ( len ) {
32+ return this . inputs . substr ( this . pos , len )
33+ }
34+
3135 startWiths ( str ) {
3236 return this . inputs . substr ( this . pos , str . length ) === str ;
3337 }
@@ -42,9 +46,18 @@ class WXMLParser {
4246 return this . inputs [ this . pos ++ ] ;
4347 }
4448
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 ) {
4658 let result = '' ;
47- while ( ! this . isEOF ( ) && matchFunc ( this . getNextChar ( ) ) ) {
59+
60+ while ( ! this . isEOF ( ) && matchFunc ( len ? this . getNextString ( len ) : this . getNextChar ( ) ) ) {
4861 result += this . consumeChar ( ) ;
4962 }
5063 return result ;
@@ -129,17 +142,17 @@ class WXMLParser {
129142 }
130143
131144 if ( tagName === 'wxs' ) {
132- const wxs = this . consumeWhile ( char => char !== '<' ) ;
145+ const wxs = this . consumeWhile ( str => str !== '</wxs' , 5 ) ;
133146 handlerCompany . call ( this , 'wxs' , wxs ) ;
134147 } else {
135148 this . parseNodes ( ) ;
136149 }
137150
138- assert . ok ( this . consumeChar ( ) === '<' ) ;
139- assert . ok ( this . consumeChar ( ) === '/' ) ;
151+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '<' ) ;
152+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '/' ) ;
140153 let closeTagName = this . parseTagName ( ) ;
141154 handlerCompany . call ( this , 'closetag' , closeTagName , false ) ;
142- assert . ok ( this . consumeChar ( ) === '>' ) ;
155+ assert . ok ( this . consumeCharIgnoreWhitespace ( ) === '>' ) ;
143156 }
144157
145158 parseTagName ( ) {
@@ -216,7 +229,6 @@ let minifier = function(source, options) {
216229 str += `</${ tagname } >` ;
217230 } ,
218231 onwxs ( wxs ) {
219- console . log ( wxs ) ;
220232 str += wxs ;
221233 }
222234 } ) ;
0 commit comments