mediawiki-extensions-Visual.../modules/ve/dm
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
..
annotations Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
lineardata docs: Minor improvements 2013-09-05 23:56:59 +00:00
metaitems ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
nodes Add alt attribute to core image nodes 2013-09-07 12:56:17 -07:00
ve.dm.Annotation.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.AnnotationFactory.js Convert AnnotationFactory and MetaItemFactory to NamedClassFactories 2013-04-09 12:05:05 -07:00
ve.dm.AnnotationSet.js Speed up openAndCloseAnnotations by using store indexes 2013-07-26 18:11:01 -07:00
ve.dm.BranchNode.js Store DM nodes in InternalList 2013-06-03 22:10:07 +01:00
ve.dm.Converter.js Fix check for preformatted when stripping whitespace 2013-09-16 16:41:45 +01:00
ve.dm.DataString.js Code style fixes 2013-05-06 12:36:52 +01:00
ve.dm.Document.js Remove no-insertion metadata corner case from ve.dm.Transaction.pushReplace(). 2013-09-06 01:07:37 +00:00
ve.dm.DocumentSlice.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.DocumentSynchronizer.js doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
ve.dm.IndexValueStore.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.InternalList.js Prevent naming collisions when generating unique reference names 2013-09-19 21:03:15 -07:00
ve.dm.js
ve.dm.LeafNode.js
ve.dm.LinearData.js docs: Minor improvements 2013-09-05 23:56:59 +00:00
ve.dm.MetaItem.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.MetaItemFactory.js Make .static.storeHtmlAttributes more versatile 2013-05-07 14:45:26 -07:00
ve.dm.MetaList.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.Model.js Add .static.getMatchRdfaTypes() wrapper 2013-08-07 17:39:24 +08:00
ve.dm.ModelRegistry.js Fix deprioritization of regex matches in ModelRegistry 2013-08-08 02:52:45 +00:00
ve.dm.Node.js doc: Fix incorrect syntax 2013-09-06 20:29:18 +00:00
ve.dm.NodeFactory.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.Surface.js dm.Surface: Initialize selection at (1,1) instead of (0,0) 2013-09-18 01:06:34 +00:00
ve.dm.SurfaceFragment.js Compare annotations by name only when clearing/toggling 2013-07-16 00:05:11 +01:00
ve.dm.Transaction.js Minor doc fixes to ve.dm.Transaction. 2013-09-18 15:18:42 +00:00
ve.dm.TransactionProcessor.js Fix processing of double metadata replacements 2013-09-11 15:26:12 -07:00