mediawiki-extensions-Visual.../modules/ve-mw/dm/nodes
Roan Kattouw eb64743436 Prevent naming collisions when generating unique reference names
Simply generating ':3' as the "unique" name for the 4th reference
doesn't work. Even if getUniqueListKey() had been used, that only
checks for conflicts with names that have already been encountered
(i.e. occur in <ref> tags that precede the current one), not for
conflicts with names that first occur further down in the document.

The solution is to generate names at serialization time, when we
have full knowledge of which names are in use. Internally, we use
'literal/<name>' for names that literally appeared in the source,
and 'auto/<number>' for unnamed references. Then at serialization
time, we translate 'auto/<number>' to 'literal/:<number>' if needed
(i.e. if the reference was reused).

ve.dm.MWReferenceNode.js:
* toDataElement()
** Prefix listKey with literal/ or auto/ as appropriate
* toDomElements()
** Map auto/ listKeys to unique names
** Don't try to unset the name if not present (was unsetting a property
   that didn't exist anyway)

ve.dm.InternalList.js:
* Remove now-unused isUniqueListKey()
* Rewrite getUniqueListKey()
** Make prefix configurable
** Take previously generated unique keys into account
** Map the same old key (auto/N) to the same generated key (literal/:M)
* Add getNextUniqueNumber() as a source for auto/N numbers: previously
  used the length of the itemHtmlQueue, but that only works during
  conversion, not from the UI dialog

ve.ui.MWReferenceDialog.js:
* For new references or conflicting names, generate an auto/N key and
  let toDomElements() deal with actually mapping that to name

ve.dm.InternalList.test.js:
* Rename listKeys to new style
* Split the test case into two groups so we can test multi-group cases
* Add tests for getUniqueListKey()

ve.dm.mwExample.js:
* Rename things to new style
* Modify the test case so it attempts to trigger bug 54341

Bug: 54341
Change-Id: I726fb83e6fb66ffec643d996768a854ec9474b3d
2013-09-19 21:03:15 -07:00
..
ve.dm.MWAlienExtensionNode.js Round trip alien extensions correctly when edited 2013-08-30 16:43:50 -07:00
ve.dm.MWBlockImageNode.js Define RDFa types in ve.dm.MWBlockImageNode once and reuse whenever possible 2013-09-05 15:52:07 -07:00
ve.dm.MWEntityNode.js The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.dm.MWExtensionNode.js Round trip alien extensions correctly when edited 2013-08-30 16:43:50 -07:00
ve.dm.MWHeadingNode.js The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.dm.MWHieroNode.js Hieroglyphics support 2013-08-07 09:43:04 +00:00
ve.dm.MWImageCaptionNode.js The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.dm.MWInlineImageNode.js Define RDFa types in ve.dm.MWInlineImageNode once and reuse whenever possible 2013-09-09 13:04:08 -07:00
ve.dm.MWMathNode.js Create base MWExtensionNode for simple extension support 2013-08-07 17:39:31 +08:00
ve.dm.MWPreformattedNode.js The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.dm.MWReferenceListNode.js Remove the DM 'about' attribute from references and reference lists 2013-07-30 15:08:19 -07:00
ve.dm.MWReferenceNode.js Prevent naming collisions when generating unique reference names 2013-09-19 21:03:15 -07:00
ve.dm.MWTransclusionNode.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00