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:
Trevor Parscal 2013-05-15 16:23:42 -07:00
parent ba5c4f104d
commit e64d900fc3

View file

@ -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':