Add some checks against undefined tokens returned from async transforms

Change-Id: Ie19537083b96b1b2e12e1c4b65a7a044753c18ac
This commit is contained in:
Gabriel Wicke 2012-05-23 16:32:21 +02:00
parent a4c5d43ff7
commit a862718ad8
2 changed files with 4 additions and 4 deletions

View file

@ -185,7 +185,7 @@ TemplateHandler.prototype._processTemplateAndTitle = function( token, frame, cb,
// Hook up the inputPipeline output events to our handlers
pipeline.addListener( 'chunk', this._onChunk.bind ( this, cb ) );
pipeline.addListener( 'end', this._onEnd.bind ( this, cb ) );
pipeline.addListener( 'end', this._onEnd.bind ( this ) );
// Feed the pipeline. XXX: Support different formats.
this.manager.env.dp( 'TemplateHandler._processTemplateAndTitle', name, attribs );
pipeline.process ( src, name );
@ -205,9 +205,9 @@ TemplateHandler.prototype._onChunk = function( cb, chunk ) {
* Handle the end event emitted by the parser pipeline after fully processing
* the template source.
*/
TemplateHandler.prototype._onEnd = function( cb ) {
TemplateHandler.prototype._onEnd = function( token, frame, cb ) {
this.manager.env.dp( 'TemplateHandler._onEnd' );
cb( { tokens: [] } );
cb( { tokens: [token] } );
};

View file

@ -436,7 +436,7 @@ AsyncTokenTransformManager.prototype.transformTokens = function ( tokens, parent
if ( resTokens && resTokens.length ) {
if ( resTokens.length === 1 ) {
if ( resTokens[0] === undefined ) {
console.warn('transformer ' + transformer +
console.warn('transformer ' + transformer.rank +
' returned undefined token!');
resTokens.shift();
break;