MWImageModel: Check selectedNode exists before asking for property

Bug: T180521
Change-Id: I1c10929abd6f5c4afa03a65904bc76fc82f8fcbb
This commit is contained in:
Ed Sanders 2018-01-08 15:31:13 +00:00
parent 767865c8ed
commit c41fd90a15

View file

@ -458,7 +458,7 @@ ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
switch ( nodeType ) {
case 'mwInlineImage':
if ( selectedNode.type === 'mwBlockImage' ) {
if ( selectedNode && selectedNode.type === 'mwBlockImage' ) {
// If converting from a block image, create a wrapper paragraph for the inline image to go in.
fragment.insertContent( [ { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: '/paragraph' } ] );
offset = fragment.getSelection().getRange().start + 1;