Do not add empty <figcaption> to <figure> tag

Change-Id: I7527f88e05318bfa6f0dbd5663294e7f0dd31a3e
This commit is contained in:
Inez Korczyński 2013-06-24 17:22:03 -07:00
parent 12bd0ab325
commit 58d752331e

View file

@ -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,10 +167,14 @@ ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter )
figure.appendChild( a );
a.appendChild( img );
// 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 <figcaption>.
if ( captionData.length > 2 ) {
converter.getDomSubtreeFromData( data.slice( 1, -1 ), wrapper );
while ( wrapper.firstChild ) {
figure.appendChild( wrapper.firstChild );
}
}
return [ figure ];
};