mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Fix protectedness of MWReferenceList
The update() method wiped out the entire contents of the node, including the shield that makes ce.ProtectedNode work. Fixed by only wiping out and reconstructing the contents of the <ol> Change-Id: Ib2978a72939884be67964ce8a3d89a570f70bfa3
This commit is contained in:
parent
4d65b6610b
commit
3aae3e80bd
|
@ -26,6 +26,8 @@ ve.ce.MWReferenceListNode = function VeCeMWReferenceListNode( model, config ) {
|
||||||
// DOM Changes
|
// DOM Changes
|
||||||
this.$.addClass( 've-ce-mwReferenceListNode', 'reference' )
|
this.$.addClass( 've-ce-mwReferenceListNode', 'reference' )
|
||||||
.attr( 'contenteditable', false );
|
.attr( 'contenteditable', false );
|
||||||
|
this.$reflist = $( '<ol class="references">' );
|
||||||
|
this.$.append( this.$reflist );
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
this.model.getDocument().internalList.connect( this, { 'update': 'onInternalListUpdate' } );
|
this.model.getDocument().internalList.connect( this, { 'update': 'onInternalListUpdate' } );
|
||||||
|
@ -45,6 +47,8 @@ ve.mixinClass( ve.ce.MWReferenceListNode, ve.ce.ProtectedNode );
|
||||||
|
|
||||||
ve.ce.MWReferenceListNode.static.name = 'mwReferenceList';
|
ve.ce.MWReferenceListNode.static.name = 'mwReferenceList';
|
||||||
|
|
||||||
|
ve.ce.MWReferenceListNode.static.tagName = 'div';
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,11 +85,11 @@ ve.ce.MWReferenceListNode.prototype.onListNodeUpdate = function () {
|
||||||
*/
|
*/
|
||||||
ve.ce.MWReferenceListNode.prototype.update = function () {
|
ve.ce.MWReferenceListNode.prototype.update = function () {
|
||||||
var i, j, iLen, jLen, key, keyNodes, $li, itemNode,
|
var i, j, iLen, jLen, key, keyNodes, $li, itemNode,
|
||||||
$ol = $( '<ol class="references">' ),
|
|
||||||
internalList = this.model.getDocument().internalList,
|
internalList = this.model.getDocument().internalList,
|
||||||
listGroup = this.model.getAttribute( 'listGroup' ),
|
listGroup = this.model.getAttribute( 'listGroup' ),
|
||||||
nodes = internalList.getNodeGroup( listGroup );
|
nodes = internalList.getNodeGroup( listGroup );
|
||||||
|
|
||||||
|
this.$reflist.empty();
|
||||||
if ( nodes && nodes.keyOrder.length ) {
|
if ( nodes && nodes.keyOrder.length ) {
|
||||||
for ( i = 0, iLen = nodes.keyOrder.length; i < iLen; i++ ) {
|
for ( i = 0, iLen = nodes.keyOrder.length; i < iLen; i++ ) {
|
||||||
key = nodes.keyOrder[i];
|
key = nodes.keyOrder[i];
|
||||||
|
@ -108,11 +112,9 @@ ve.ce.MWReferenceListNode.prototype.update = function () {
|
||||||
internalList.getItemNode( keyNodes[0].getAttribute( 'listIndex' ) )
|
internalList.getItemNode( keyNodes[0].getAttribute( 'listIndex' ) )
|
||||||
);
|
);
|
||||||
$li.append( $( '<span class="reference-text">' ).html( itemNode.$.show() ) );
|
$li.append( $( '<span class="reference-text">' ).html( itemNode.$.show() ) );
|
||||||
$ol.append( $li );
|
this.$reflist.append( $li );
|
||||||
}
|
}
|
||||||
} // TODO: Show a placeholder for an empty reference list in the 'else' section
|
} // TODO: Show a placeholder for an empty reference list in the 'else' section
|
||||||
|
|
||||||
this.$.html( $ol );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Registration */
|
/* Registration */
|
||||||
|
|
Loading…
Reference in a new issue