From 5ce6faf0205f5d761224f0b6218d390a0786f649 Mon Sep 17 00:00:00 2001 From: David Chan Date: Sat, 2 May 2015 12:52:40 +0800 Subject: [PATCH] Zero-width space to avoid empty annotation cursoring bug Add zero-width space to make span-like tags non-empty, so that the browser won't merge their cursoring positions with the following character. ve.ce.MWNumberedExternalLinkNode: * Insert U+200B ZERO WIDTH SPACE inside span (before 'a' tag). Bug: T96307 Change-Id: Ib07f732043eae4640e3dcfdc06015bcf8897c7b4 --- .../ce/nodes/ve.ce.MWNumberedExternalLinkNode.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWNumberedExternalLinkNode.js b/modules/ve-mw/ce/nodes/ve.ce.MWNumberedExternalLinkNode.js index bd1af360f5..a8d3b541bf 100644 --- a/modules/ve-mw/ce/nodes/ve.ce.MWNumberedExternalLinkNode.js +++ b/modules/ve-mw/ce/nodes/ve.ce.MWNumberedExternalLinkNode.js @@ -23,7 +23,19 @@ ve.ce.MWNumberedExternalLinkNode = function VeCeMWNumberedExternalLinkNode( mode ve.ce.FocusableNode.call( this ); // DOM changes - this.$element.addClass( 've-ce-mwNumberedExternalLinkNode' ); + this.$element + // TODO: Test to see whether we can get away with adding unicode-bidi + // embed/isolate style on $element. unicode-bidi isolate is more conceptually + // correct, but not well supported (e.g. it seems to result in unexpected jumping + // on Chromium). + .addClass( 've-ce-mwNumberedExternalLinkNode' ) + // Need some content to make span take up a cursor position, but it must be text + // with no directionality, else it can break Chromium cursoring (see + // https://code.google.com/p/chromium/issues/detail?id=441056 ). Either a + // unicorn-like img tag or the actual apparent link text ("[1]", hitherto shown + // with CSS generated content) would fall foul of this bug. Use a zero-width + // space so it doesn't change the appearance. + .text( '\u200B' ); // Add link this.$link = $( '' )