From 9beb92a10257024745b9e26ddc3b3541380b0bb4 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 25 Apr 2014 16:13:31 -0700 Subject: [PATCH] Delete extensions nodes which have been made empty If they have allowedEmpty=false. Also remove unnecessary instanceof check. Change-Id: I388202c9da5673534486b1d9d345296feeec53c3 --- modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js index dc0a5e2aec..fd22b0b351 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js @@ -122,7 +122,7 @@ ve.ui.MWExtensionInspector.prototype.teardown = function ( data ) { surfaceModel = this.getFragment().getSurface(); if ( this.constructor.static.allowedEmpty || this.input.getValue() !== '' ) { - if ( this.node instanceof this.constructor.static.nodeModel ) { + if ( this.node ) { mwData = ve.copy( this.node.getAttribute( 'mw' ) ); this.updateMwData( mwData ); surfaceModel.change( @@ -147,6 +147,10 @@ ve.ui.MWExtensionInspector.prototype.teardown = function ( data ) { { 'type': '/' + this.constructor.static.nodeModel.static.name } ] ); } + } else if ( this.node && !this.constructor.static.allowedEmpty ) { + // Content has been emptied on a node which isn't allowed to + // be empty, so delete it. + surfaceModel.getFragment().removeContent(); } // Parent method