From 31df8ff3a890d0e3b30d185e1193871bf048998e Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 31 Mar 2014 16:07:59 -0700 Subject: [PATCH] Emit rerender on math node if Tex image is not present This happens with then empty tag is rendered. Bug: 63093 Change-Id: I5cf731cedda134d2542946da82997bddf58b00b5 --- modules/VisualEditor/ve.ce.MWMathNode.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/VisualEditor/ve.ce.MWMathNode.js b/modules/VisualEditor/ve.ce.MWMathNode.js index d5dd2ed..54ee39d 100644 --- a/modules/VisualEditor/ve.ce.MWMathNode.js +++ b/modules/VisualEditor/ve.ce.MWMathNode.js @@ -48,7 +48,9 @@ ve.ce.MWMathNode.prototype.onParseSuccess = function ( deferred, response ) { }; /** */ -ve.ce.MWExtensionNode.prototype.afterRender = function ( domElements ) { +ve.ce.MWMathNode.prototype.afterRender = function ( domElements ) { + var $img; + if ( this.$( domElements ).is( 'span.tex' ) ) { // MathJax MathJax.Hub.Queue( @@ -56,10 +58,16 @@ ve.ce.MWExtensionNode.prototype.afterRender = function ( domElements ) { [ this, this.emit, 'rerender' ] ); } else { + $img = this.$element.find( 'img.tex' ); // Rerender after image load - this.$element.find( 'img.tex' ).on( 'load', ve.bind( function () { + if ( $img.length ) { + $img.on( 'load', ve.bind( function () { + this.emit( 'rerender' ); + }, this ) ); + } else { + // Passing an empty string returns no image, so rerender immediately this.emit( 'rerender' ); - }, this ) ); + } } };