Page MenuHomePhabricator

document.selection.createRange should not be unconditionally accessed in MSIE (document.selection was removed in IE11)
Closed, ResolvedPublic

Description

document.selection is no longer supported in IE11, that breaks some browser compatibility checks in WikiEditor and therefor the dialogs for links and images.

document.selection.createRange is accessed without check of document.selection, that gives a javascript error.

I am not sure, if it is enough to replace the msie check with a check for document.selection && document.selection.createRange or to add a version to the check.

See http://msdn.microsoft.com/en-us/library/ie/ms535869(v=vs.85).aspx

Thanks.


Version: master
Severity: major

Details

Reference
bz57489

Event Timeline

bzimport raised the priority of this task from to Unbreak Now!.Nov 22 2014, 2:40 AM
bzimport set Reference to bz57489.
bzimport added a subscriber: Unknown Object (MLST).

core makes it right in resource/jquery/jquery.textSelection.js

More users updates her browsers to IE11, so there are more and more questions at least on the german village pump -> bumping priority, because this is a new browser version, not a old one.

$:andre\> grep -r "document.selection" .
./modules/jquery.wikiEditor.iframe.js:
if ( !e && context.$iframe[0].contentWindow.document.selection ) {
var range = context.$iframe[0].contentWindow.document.selection.createRange();
context.savedSelection = context.$iframe[0].contentWindow.document.selection.createRange();
} else if ( context.$iframe[0].contentWindow.document.selection ) { should come last; Opera!
var selection = context.$iframe[0].contentWindow.document.selection.createRange();
} else if ( context.$iframe[0].contentWindow.document.selection ) {
should come last; Opera!
retval = context.$iframe[0].contentWindow.document.selection.createRange();
} else if ( context.$iframe[0].contentWindow.document.selection ) {
var range = context.$iframe[0].contentWindow.document.selection.createRange();
var range2 = context.$iframe[0].contentWindow.document.selection.createRange();
var range3 = context.$iframe[0].contentWindow.document.selection.createRange();
} else if ( context.$iframe[0].contentWindow.document.selection ) {
./modules/jquery.wikiEditor.js:

		context.savedSelection = document.selection.createRange();

The fatal is on:

/**

  • Save text selection for IE */

saveSelection: function () {
if ( $.client.profile().name === 'msie' ) {

		context.$textarea.focus();
		context.savedSelection = document.selection.createRange();

}
},

That is easy to fix by adding "&& document.selection " to the if, but when grep for 'msie' you will found this:

/**

  • Save scrollTop and cursor position for IE */

saveCursorAndScrollTop: function () {
if ( $.client.profile().name === 'msie' ) {

		var IHateIE = {
			'scrollTop' : context.$textarea.scrollTop(),
			'pos': context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } )
		};
		context.$textarea.data( 'IHateIE', IHateIE );

}
},

And I cannot say, if that is still needed in IE11. I cannot test IE11 at the moment.

mr.heat wrote:

Who is responsible for the extension? More users are asking for this: https://de.wikipedia.org/wiki/Wikipedia:Fragen_zur_Wikipedia#Editieren_mit_IE11

(In reply to comment #5)

Who is responsible for the extension?

All maintainers that I am aware of are CC'ed.
For future reference, see also "Author(s)" on http://www.mediawiki.org/wiki/Extension:WikiEditor and https://www.mediawiki.org/wiki/Developers/Maintainers

Change 105517 had a related patch set uploaded by Umherirrender:
document.selection is undefined in IE11

https://gerrit.wikimedia.org/r/105517

Change 105517 merged by jenkins-bot:
document.selection is undefined in IE11

https://gerrit.wikimedia.org/r/105517

  • Bug 66531 has been marked as a duplicate of this bug. ***