mediawiki-extensions-Visual.../modules/ve
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
..
ce Fix pawn on pre-annotation and keypress 2013-09-11 19:47:39 -07:00
dm Prevent naming collisions when generating unique reference names 2013-09-19 21:03:15 -07:00
init Add keyboard shortcuts for formatting tools 2013-09-03 17:17:03 -07:00
test dm.Surface: Initialize selection at (1,1) instead of (0,0) 2013-09-18 01:06:34 +00:00
ui Scroll into view support 2013-09-16 16:46:58 -07:00
ve.BranchNode.js Kill getOffsetFromNode() with fire 2013-05-09 17:26:22 -07:00
ve.debug.js ve.debug: Document why we use global Function#apply+Function#call instead of method.apply 2013-05-30 13:03:14 +01:00
ve.Document.js doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
ve.Element.js Scroll into view support 2013-09-16 16:46:58 -07:00
ve.EventEmitter.js oojs: Integrate with OOJS v1.0.0 2013-06-06 17:29:55 +02:00
ve.EventSequencer.js Fix function naming conventions, comments and whitespace 2013-09-17 19:37:08 +01:00
ve.Factory.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.js Include element HTML in QUnit summary for diff 2013-08-02 16:10:05 +01:00
ve.LeafNode.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.NamedClassFactory.js Rename ve.NodeFactory to ve.NamedClassFactory 2013-04-09 12:05:05 -07:00
ve.Node.js ve.ce.Document: Introduce getRelativeRange method 2013-06-05 13:10:38 +01:00
ve.Range.js doc: Fix incorrect syntax 2013-09-06 20:29:18 +00:00
ve.Registry.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.track.js Add ve.track, a generic dispatch of analytic events 2013-08-03 02:51:07 +00:00