mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Add some checks against undefined tokens returned from async transforms
Change-Id: Ie19537083b96b1b2e12e1c4b65a7a044753c18ac
This commit is contained in:
parent
a4c5d43ff7
commit
a862718ad8
|
@ -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] } );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue