From: Bartosz DziewoƄski Date: Mon, 5 Feb 2018 22:13:50 +0000 (+0100) Subject: jquery.textSelection: Remove incorrect browser hack for old Opera X-Git-Tag: 1.31.0-rc.0~672 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=5db74eb56e425ba803b2cc936fbe3e5cc219b482;hp=82e996b8c63e1f49525020ad71082c366b9567ba jquery.textSelection: Remove incorrect browser hack for old Opera This code appears to be incorrect, at least on Opera 12.18 on Windows 10, where I just tested it. It causes the selection to be misaligned, rather than correct it. For example, the following code: $textbox.textSelection( 'encapsulateSelection', { peri: 'foo\nfoo' } ); Causes the selection to extend one character past the inserted text with the hack, and to be shown correctly without the hack. It is theoretically possible that this hack was necessary for some other operating system, but then it should have also been applied to 'insertText'. Also, Opera 12 only has a usage share (barely) large enough to show up on on Windows (XP). Change-Id: Ifee877c6202bcfc0fecb65220e34b4b39659dbeb --- diff --git a/resources/src/jquery/jquery.textSelection.js b/resources/src/jquery/jquery.textSelection.js index 7ec9882670..27d5fc790c 100644 --- a/resources/src/jquery/jquery.textSelection.js +++ b/resources/src/jquery/jquery.textSelection.js @@ -205,11 +205,6 @@ this.value.slice( endPos ); // Setting this.value scrolls the textarea to the top, restore the scroll position this.scrollTop = scrollTop; - if ( window.opera ) { - pre = pre.replace( /\r?\n/g, '\r\n' ); - selText = selText.replace( /\r?\n/g, '\r\n' ); - post = post.replace( /\r?\n/g, '\r\n' ); - } if ( isSample && options.selectPeri && ( !options.splitlines || ( options.splitlines && selText.indexOf( '\n' ) === -1 ) ) ) { this.selectionStart = startPos + pre.length; this.selectionEnd = startPos + pre.length + selText.length;