mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Fix broken deletion of non-existing <ref refGroup="…">
This can be quite confusing: * A node does have attributes. One of the attributes is called "refGroup", another one "mw". * mw contains a JSON structure with just a few elements, most notably a "body" and an "attrs" element. These reflect what was originally written in the wikitext. * mw.attrs reflects the original properties a.k.a. attributes from the <ref …> or <references …> tag. Deleting mw.refGroup doesn't do anything because the attribute is called <ref group="…"> in the wikitext, not <ref refGroup="…">. You can actually see this bug in action on all wikis: Go to a page that uses references in non-standard groups, e.g. https://en.wikipedia.org/wiki/Historic_Cherokee_settlements Start VisualEditor. Find e.g. the [notes 1] reference. Edit it and change the group from "notes" to "General references". Click "Publish…" and "Review" your changes. The visual diff works because it apparently uses other information. The wikitext diff is empty. This is also what's saved: nothing. The edit is lost. Bug: T359943 Change-Id: I798605d2fd60a6b8f317ec85a4e4d08fd245e084
This commit is contained in:
parent
90dc52620c
commit
ae786bc2ef
|
@ -232,7 +232,7 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
|
|||
if ( dataElement.attributes.refGroup !== '' ) {
|
||||
ve.setProp( mwData, 'attrs', 'group', dataElement.attributes.refGroup );
|
||||
} else if ( mwData.attrs ) {
|
||||
delete mwData.attrs.refGroup;
|
||||
delete mwData.attrs.group;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ ve.dm.MWReferencesListNode.static.toDomElements = function ( data, doc, converte
|
|||
if ( attrs.refGroup ) {
|
||||
ve.setProp( mwData, 'attrs', 'group', attrs.refGroup );
|
||||
} else if ( mwData.attrs ) {
|
||||
delete mwData.attrs.refGroup;
|
||||
delete mwData.attrs.group;
|
||||
}
|
||||
|
||||
const originalMw = attrs.originalMw;
|
||||
|
|
Loading…
Reference in a new issue