mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Apply DOM changes in onProtectedSetup and onProtectedTeardown instead of constructor
It's important in case of replacing root element ($) of a node, so new element does have CSS class and contenteditable property set. Change-Id: Icf14e2164e89114e6b7c10672b782d02f4c5daac
This commit is contained in:
parent
27dfe83e6f
commit
301b287515
|
@ -37,9 +37,8 @@ QUnit.test( 'getRenderedContents', function ( assert ) {
|
|||
],
|
||||
'html': 'a<b>b<span typeof="mw:Entity" class="ve-ce-leafNode ' +
|
||||
've-ce-mwEntityNode" contenteditable="false">c</span>d<span ' +
|
||||
'class="ve-ce-leafNode ve-ce-protectedNode ve-ce-generatedContentNode ' +
|
||||
've-ce-alienNode ve-ce-alienInlineNode" ' +
|
||||
'contenteditable="false"><tt>e</tt></span></b>'
|
||||
'class="ve-ce-leafNode ve-ce-generatedContentNode ' +
|
||||
've-ce-alienNode ve-ce-alienInlineNode"><tt>e</tt></span></b>'
|
||||
}
|
||||
];
|
||||
QUnit.expect( cases.length );
|
||||
|
|
|
@ -26,11 +26,6 @@ ve.ce.ProtectedNode = function VeCeProtectedNode( $phantomable ) {
|
|||
'setup': 'onProtectedSetup',
|
||||
'teardown': 'onProtectedTeardown'
|
||||
} );
|
||||
|
||||
// DOM changes
|
||||
this.$
|
||||
.addClass( 've-ce-protectedNode' )
|
||||
.prop( 'contentEditable', 'false' );
|
||||
};
|
||||
|
||||
/* Static Properties */
|
||||
|
@ -85,6 +80,11 @@ ve.ce.ProtectedNode.prototype.onProtectedSetup = function () {
|
|||
this.getRoot().getSurface().getSurface()
|
||||
.connect( this, { 'position': 'positionPhantoms' } );
|
||||
|
||||
// DOM changes
|
||||
this.$
|
||||
.addClass( 've-ce-protectedNode' )
|
||||
.prop( 'contentEditable', 'false' );
|
||||
|
||||
// Shields
|
||||
this.$.add( this.$.find( '*' ) ).each( function () {
|
||||
var $this = $( this );
|
||||
|
@ -130,6 +130,11 @@ ve.ce.ProtectedNode.prototype.onProtectedTeardown = function () {
|
|||
// Phantoms
|
||||
this.clearPhantoms();
|
||||
|
||||
// DOM changes
|
||||
this.$
|
||||
.removeClass( 've-ce-protectedNode' )
|
||||
.removeProp( 'contentEditable' );
|
||||
|
||||
this.isSetup = false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue