From c41fd90a15998f2e88a7a5a7abce8b198a826f9c Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 8 Jan 2018 15:31:13 +0000 Subject: [PATCH] MWImageModel: Check selectedNode exists before asking for property Bug: T180521 Change-Id: I1c10929abd6f5c4afa03a65904bc76fc82f8fcbb --- modules/ve-mw/dm/models/ve.dm.MWImageModel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js index 600705ae3d..8b727b935d 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js @@ -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;