mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 15:04:02 +00:00
Render reference list from originalDomElements until modified
This helps on wikis where there are no real refs because they are template-generated, and is a performance improvement elsewhere as re-rendering long ref lists can be slow. Bug: T187495 Change-Id: I47a9206ff7ee61f8fd716dc7658b8bfad927f656
This commit is contained in:
parent
a068a3a379
commit
f739008cbd
|
@ -26,10 +26,12 @@ ve.ce.MWReferencesListNode = function VeCeMWReferencesListNode() {
|
|||
// Properties
|
||||
this.internalList = null;
|
||||
this.listNode = null;
|
||||
this.modified = false;
|
||||
|
||||
// DOM changes
|
||||
this.$element.addClass( 've-ce-mwReferencesListNode' );
|
||||
this.$reflist = $( '<ol>' ).addClass( 'mw-references references' );
|
||||
this.$originalRefList = null;
|
||||
this.$refmsg = $( '<p>' )
|
||||
.addClass( 've-ce-mwReferencesListNode-muted' );
|
||||
|
||||
|
@ -110,6 +112,7 @@ ve.ce.MWReferencesListNode.prototype.onTeardown = function () {
|
|||
ve.ce.MWReferencesListNode.prototype.onInternalListUpdate = function ( groupsChanged ) {
|
||||
// Only update if this group has been changed
|
||||
if ( groupsChanged.indexOf( this.model.getAttribute( 'listGroup' ) ) !== -1 ) {
|
||||
this.modified = true;
|
||||
this.updateDebounced();
|
||||
}
|
||||
};
|
||||
|
@ -125,6 +128,7 @@ ve.ce.MWReferencesListNode.prototype.onAttributeChange = function ( key ) {
|
|||
switch ( key ) {
|
||||
case 'listGroup':
|
||||
this.updateDebounced();
|
||||
this.modified = true;
|
||||
break;
|
||||
case 'isResponsive':
|
||||
this.updateClasses();
|
||||
|
@ -157,6 +161,17 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
|||
listGroup = this.model.getAttribute( 'listGroup' ),
|
||||
nodes = internalList.getNodeGroup( listGroup );
|
||||
|
||||
// Just use Parsoid-provided DOM for first rendering
|
||||
// NB: Technically this.modified could be reset to false if this
|
||||
// node is re-attached, but that is an unlikely edge case.
|
||||
if ( !this.modified && this.model.getElement().originalDomElementsIndex ) {
|
||||
this.$originalRefList = $( this.model.getStore().value(
|
||||
this.model.getElement().originalDomElementsIndex
|
||||
) );
|
||||
this.$element.append( this.$originalRefList );
|
||||
return;
|
||||
}
|
||||
|
||||
function updateGeneratedContent( viewNode, $li ) {
|
||||
// HACK: PHP parser doesn't wrap single lines in a paragraph
|
||||
if (
|
||||
|
@ -179,6 +194,10 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
|||
viewNode.destroy();
|
||||
}
|
||||
|
||||
if ( this.$originalRefList ) {
|
||||
this.$originalRefList.remove();
|
||||
this.$originalRefList = null;
|
||||
}
|
||||
this.$reflist.detach().empty();
|
||||
this.$refmsg.detach();
|
||||
|
||||
|
|
Loading…
Reference in a new issue