From ae786bc2efc7ce0ca5cb05cf3ced7e6ed318be54 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Wed, 21 Feb 2024 13:27:19 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20broken=20deletion=20of=20non-existing=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 or tag. Deleting mw.refGroup doesn't do anything because the attribute is called in the wikitext, not . 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 --- modules/ve-cite/ve.dm.MWReferenceNode.js | 2 +- modules/ve-cite/ve.dm.MWReferencesListNode.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ve-cite/ve.dm.MWReferenceNode.js b/modules/ve-cite/ve.dm.MWReferenceNode.js index 29628449b..5440fcc2a 100644 --- a/modules/ve-cite/ve.dm.MWReferenceNode.js +++ b/modules/ve-cite/ve.dm.MWReferenceNode.js @@ -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; } } diff --git a/modules/ve-cite/ve.dm.MWReferencesListNode.js b/modules/ve-cite/ve.dm.MWReferencesListNode.js index b941fdace..2f440ae27 100644 --- a/modules/ve-cite/ve.dm.MWReferencesListNode.js +++ b/modules/ve-cite/ve.dm.MWReferencesListNode.js @@ -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;