mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Do not add empty <figcaption> to <figure> tag
Change-Id: I7527f88e05318bfa6f0dbd5663294e7f0dd31a3e
This commit is contained in:
parent
12bd0ab325
commit
58d752331e
|
@ -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 ];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue