@@ -234,33 +234,41 @@ XMLP.prototype._parse = function() {
234
234
return XMLP . _NONE ;
235
235
}
236
236
237
+ function _indexOf ( needle , haystack , start ) {
238
+ // This is an improvement over the native indexOf because it stops at the
239
+ // end of the needle and doesn't continue to the end of the haystack looking.
240
+ for ( var i = 0 ; i < needle . length ; i ++ ) {
241
+ if ( needle . charAt ( i ) != haystack . charAt ( start + i ) )
242
+ return - 1 ;
243
+ }
244
+ return start ;
245
+ }
246
+
237
247
var fc = this . m_xml . charAt ( this . m_iP ) ;
238
248
if ( fc !== '<' && fc !== '&' ) {
239
- return this . _parseText ( this . m_iP ) ;
240
- }
241
- else if ( this . m_iP == this . m_xml . indexOf ( "<?" , this . m_iP ) ) {
249
+ return this . _parseText ( this . m_iP ) ;
250
+ }
251
+ else if ( this . m_iP == _indexOf ( "<?" , this . m_xml , this . m_iP ) ) {
242
252
return this . _parsePI ( this . m_iP + 2 ) ;
243
253
}
244
- else if ( this . m_iP == this . m_xml . indexOf ( "<!DOCTYPE" , this . m_iP ) ) {
254
+ else if ( this . m_iP == _indexOf ( "<!DOCTYPE" , this . m_xml , this . m_iP ) ) {
245
255
return this . _parseDTD ( this . m_iP + 9 ) ;
246
256
}
247
- else if ( this . m_iP == this . m_xml . indexOf ( "<!--" , this . m_iP ) ) {
257
+ else if ( this . m_iP == _indexOf ( "<!--" , this . m_xml , this . m_iP ) ) {
248
258
return this . _parseComment ( this . m_iP + 4 ) ;
249
259
}
250
- else if ( this . m_iP == this . m_xml . indexOf ( "<![CDATA[" , this . m_iP ) ) {
260
+ else if ( this . m_iP == _indexOf ( "<![CDATA[" , this . m_xml , this . m_iP ) ) {
251
261
return this . _parseCDATA ( this . m_iP + 9 ) ;
252
262
}
253
- else if ( this . m_iP == this . m_xml . indexOf ( "<" , this . m_iP ) ) {
263
+ else if ( this . m_iP == _indexOf ( "<" , this . m_xml , this . m_iP ) ) {
254
264
return this . _parseElement ( this . m_iP + 1 ) ;
255
265
}
256
- else if ( this . m_iP == this . m_xml . indexOf ( "&" , this . m_iP ) ) {
266
+ else if ( this . m_iP == _indexOf ( "&" , this . m_xml , this . m_iP ) ) {
257
267
return this . _parseEntity ( this . m_iP + 1 ) ;
258
268
}
259
269
else {
260
270
return this . _parseText ( this . m_iP ) ;
261
271
}
262
-
263
-
264
272
}
265
273
266
274
////////// NAMESPACE SUPPORT //////////////////////////////////////////
@@ -839,10 +847,15 @@ SaxParser.prototype.pause = function() {
839
847
SaxParser . prototype . resume = function ( ) {
840
848
//reset the state
841
849
this . m_parser . resume ( ) ;
850
+ this . m_interrupted = false ;
851
+
842
852
//now start up the parse loop
843
853
var that = this ;
844
854
setTimeout ( function ( ) {
845
855
that . _parseLoop ( ) ;
856
+ if ( ! that . m_bErr && ! that . m_interrupted ) {
857
+ that . _fireEvent ( SaxParser . DOC_E ) ;
858
+ }
846
859
} , 0 ) ;
847
860
}
848
861
0 commit comments