mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Fix image block node error
When loading an image block node in the demo, there are no classes on the figure, which caused the code to crash because it was assuming that jQuery's attr method would always return a string. Change-Id: Ib13e7bfa3fb2bd76ac71dfef085bed209d880b4a
This commit is contained in:
parent
ba5c4f104d
commit
e64d900fc3
|
@ -39,7 +39,7 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
|
|||
$img = $a.children( 'img' ).eq( 0 ),
|
||||
$caption = $figure.children( 'figcaption' ).eq( 0 ),
|
||||
typeofAttr = $figure.attr( 'typeof' ),
|
||||
classes = $figure.attr( 'class' ).replace( /\s{2,}/g, ' ' ).split( ' ' ),
|
||||
classes = $figure.attr( 'class' ),
|
||||
attributes = {
|
||||
href: $a.attr( 'href' ),
|
||||
src: $img.attr( 'src' ),
|
||||
|
@ -48,6 +48,10 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
|
|||
resource: $img.attr( 'resource' )
|
||||
};
|
||||
|
||||
// Extract individual classes
|
||||
classes = typeof classes === 'string' ?
|
||||
classes.replace( /\s{2,}/g, ' ' ).split( ' ' ) : [];
|
||||
|
||||
// Type
|
||||
switch ( typeofAttr ) {
|
||||
case 'mw:Image/Thumb':
|
||||
|
|
Loading…
Reference in a new issue