From 58d752331eb47e4c82cb36efc8e024768c7f3637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inez=20Korczyn=CC=81ski?= Date: Mon, 24 Jun 2013 17:22:03 -0700 Subject: [PATCH] Do not add empty
to
tag Change-Id: I7527f88e05318bfa6f0dbd5663294e7f0dd31a3e --- modules/ve/dm/nodes/ve.dm.MWBlockImageNode.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/ve/dm/nodes/ve.dm.MWBlockImageNode.js b/modules/ve/dm/nodes/ve.dm.MWBlockImageNode.js index 592e8f9702..7f39cd9fbf 100644 --- a/modules/ve/dm/nodes/ve.dm.MWBlockImageNode.js +++ b/modules/ve/dm/nodes/ve.dm.MWBlockImageNode.js @@ -117,7 +117,8 @@ ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter ) img = doc.createElement( 'img' ), wrapper = doc.createElement( 'div' ), classes = [], - originalClasses = dataElement.attributes.originalClasses; + originalClasses = dataElement.attributes.originalClasses, + captionData = data.slice( 1, -1 ); // Type switch ( dataElement.attributes.type ) { @@ -166,9 +167,13 @@ ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter ) figure.appendChild( a ); a.appendChild( img ); - converter.getDomSubtreeFromData( data.slice( 1, -1 ), wrapper ); - while ( wrapper.firstChild ) { - figure.appendChild( wrapper.firstChild ); + // If length of captionData is smaller or equal to 2 it means that there is no caption or that + // it is empty - in both cases we are going to skip appending
. + if ( captionData.length > 2 ) { + converter.getDomSubtreeFromData( data.slice( 1, -1 ), wrapper ); + while ( wrapper.firstChild ) { + figure.appendChild( wrapper.firstChild ); + } } return [ figure ]; };