mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Drop separate MWReferenceModel.parentDoc property
We can re-use the existing this.deferDoc property to achieve the same. There is apparently no need for a separate "parentDoc" property for anything else but what can be seen in this patch. https://codesearch.wmcloud.org/search/?q=%5CbparentDoc%5Cb And no need to keep neither the parentDoc reference nor deferDoc callback indefinitely. We can drop it after it got resolved. This really just moves existing code around without changing anything. Bug: T363096 Change-Id: I3c9b9bbdff29a3f35d5a0710b48ca59bf592c6ab
This commit is contained in:
parent
646f167a2b
commit
f61b840dc8
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @constructor
|
||||
* @mixes OO.EventEmitter
|
||||
* @param {ve.dm.Document} parentDoc Document that contains or will contain the reference
|
||||
* @param {ve.dm.Document} [parentDoc] Document that contains or will contain the reference
|
||||
*/
|
||||
ve.dm.MWReferenceModel = function VeDmMWReferenceModel( parentDoc ) {
|
||||
// Mixin constructors
|
||||
|
@ -25,8 +25,12 @@ ve.dm.MWReferenceModel = function VeDmMWReferenceModel( parentDoc ) {
|
|||
this.listIndex = null;
|
||||
this.group = '';
|
||||
this.doc = null;
|
||||
this.parentDoc = parentDoc;
|
||||
this.deferDoc = null;
|
||||
this.deferDoc = () => parentDoc.cloneWithData( [
|
||||
{ type: 'paragraph', internal: { generated: 'wrapper' } },
|
||||
{ type: '/paragraph' },
|
||||
{ type: 'internalList' },
|
||||
{ type: '/internalList' }
|
||||
] );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -45,7 +49,7 @@ ve.dm.MWReferenceModel.static.newFromReferenceNode = function ( node ) {
|
|||
const doc = node.getDocument();
|
||||
const internalList = doc.getInternalList();
|
||||
const attr = node.getAttributes();
|
||||
const ref = new ve.dm.MWReferenceModel( doc );
|
||||
const ref = new ve.dm.MWReferenceModel();
|
||||
|
||||
ref.setExtendsRef( attr.extendsRef );
|
||||
ref.setListKey( attr.listKey );
|
||||
|
@ -228,16 +232,8 @@ ve.dm.MWReferenceModel.prototype.getGroup = function () {
|
|||
*/
|
||||
ve.dm.MWReferenceModel.prototype.getDocument = function () {
|
||||
if ( !this.doc ) {
|
||||
if ( this.deferDoc ) {
|
||||
this.doc = this.deferDoc();
|
||||
} else {
|
||||
this.doc = this.parentDoc.cloneWithData( [
|
||||
{ type: 'paragraph', internal: { generated: 'wrapper' } },
|
||||
{ type: '/paragraph' },
|
||||
{ type: 'internalList' },
|
||||
{ type: '/internalList' }
|
||||
] );
|
||||
}
|
||||
this.doc = this.deferDoc();
|
||||
delete this.deferDoc;
|
||||
}
|
||||
return this.doc;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue