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 ' +
|
'html': 'a<b>b<span typeof="mw:Entity" class="ve-ce-leafNode ' +
|
||||||
've-ce-mwEntityNode" contenteditable="false">c</span>d<span ' +
|
've-ce-mwEntityNode" contenteditable="false">c</span>d<span ' +
|
||||||
'class="ve-ce-leafNode ve-ce-protectedNode ve-ce-generatedContentNode ' +
|
'class="ve-ce-leafNode ve-ce-generatedContentNode ' +
|
||||||
've-ce-alienNode ve-ce-alienInlineNode" ' +
|
've-ce-alienNode ve-ce-alienInlineNode"><tt>e</tt></span></b>'
|
||||||
'contenteditable="false"><tt>e</tt></span></b>'
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
QUnit.expect( cases.length );
|
QUnit.expect( cases.length );
|
||||||
|
|
|
@ -26,11 +26,6 @@ ve.ce.ProtectedNode = function VeCeProtectedNode( $phantomable ) {
|
||||||
'setup': 'onProtectedSetup',
|
'setup': 'onProtectedSetup',
|
||||||
'teardown': 'onProtectedTeardown'
|
'teardown': 'onProtectedTeardown'
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// DOM changes
|
|
||||||
this.$
|
|
||||||
.addClass( 've-ce-protectedNode' )
|
|
||||||
.prop( 'contentEditable', 'false' );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Static Properties */
|
/* Static Properties */
|
||||||
|
@ -85,6 +80,11 @@ ve.ce.ProtectedNode.prototype.onProtectedSetup = function () {
|
||||||
this.getRoot().getSurface().getSurface()
|
this.getRoot().getSurface().getSurface()
|
||||||
.connect( this, { 'position': 'positionPhantoms' } );
|
.connect( this, { 'position': 'positionPhantoms' } );
|
||||||
|
|
||||||
|
// DOM changes
|
||||||
|
this.$
|
||||||
|
.addClass( 've-ce-protectedNode' )
|
||||||
|
.prop( 'contentEditable', 'false' );
|
||||||
|
|
||||||
// Shields
|
// Shields
|
||||||
this.$.add( this.$.find( '*' ) ).each( function () {
|
this.$.add( this.$.find( '*' ) ).each( function () {
|
||||||
var $this = $( this );
|
var $this = $( this );
|
||||||
|
@ -130,6 +130,11 @@ ve.ce.ProtectedNode.prototype.onProtectedTeardown = function () {
|
||||||
// Phantoms
|
// Phantoms
|
||||||
this.clearPhantoms();
|
this.clearPhantoms();
|
||||||
|
|
||||||
|
// DOM changes
|
||||||
|
this.$
|
||||||
|
.removeClass( 've-ce-protectedNode' )
|
||||||
|
.removeProp( 'contentEditable' );
|
||||||
|
|
||||||
this.isSetup = false;
|
this.isSetup = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue