mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Fix regression to auto-save
Cite's MWDocumentReferences included a Document, which caused auto-save serialization to fail silently on the cyclical reference. This patch moves the caching to per-instance scope, which was the better choice to begin with. The document refs are recalculated after each change anyway, and caching is only necessary to work around an awkward control flow in which each ReferenceNode is responsible for its footnote number. Bug: T377484 Change-Id: Iebe4befd603fe07d9da2a5bb6126228ec4d5dfea
This commit is contained in:
parent
74ce9db4d4
commit
b3e8737829
|
@ -47,15 +47,15 @@ OO.mixinClass( ve.dm.MWDocumentReferences, OO.EventEmitter );
|
||||||
*/
|
*/
|
||||||
ve.dm.MWDocumentReferences.static.refsForDoc = function ( doc ) {
|
ve.dm.MWDocumentReferences.static.refsForDoc = function ( doc ) {
|
||||||
let docRefs;
|
let docRefs;
|
||||||
|
// Only use cache if we're working with the full document.
|
||||||
if ( !doc.getOriginalDocument() ) {
|
if ( !doc.getOriginalDocument() ) {
|
||||||
// Only use cache if we're working with the full document.
|
docRefs = doc.extCiteDocumentReferences;
|
||||||
docRefs = doc.getStorage( 'document-references-store' );
|
|
||||||
}
|
}
|
||||||
if ( docRefs === undefined ) {
|
if ( docRefs === undefined ) {
|
||||||
docRefs = new ve.dm.MWDocumentReferences( doc );
|
docRefs = new ve.dm.MWDocumentReferences( doc );
|
||||||
}
|
}
|
||||||
if ( !doc.getOriginalDocument() ) {
|
if ( !doc.getOriginalDocument() ) {
|
||||||
doc.setStorage( 'document-references-store', docRefs );
|
doc.extCiteDocumentReferences = docRefs;
|
||||||
}
|
}
|
||||||
return docRefs;
|
return docRefs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,9 +9,8 @@ function getFragmentMock( hasRefs ) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getDocument: () => ( {
|
getDocument: () => ( {
|
||||||
getOriginalDocument: () => undefined,
|
extCiteDocumentReferences: docRefsMock,
|
||||||
getStorage: () => docRefsMock,
|
getOriginalDocument: () => undefined
|
||||||
setStorage: () => undefined
|
|
||||||
} ),
|
} ),
|
||||||
getSelection: () => ( {
|
getSelection: () => ( {
|
||||||
getName: () => 'linear'
|
getName: () => 'linear'
|
||||||
|
|
Loading…
Reference in a new issue