From 37a1deb79910fed0dd04a7faeb4682afa0949e09 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 5 Jan 2014 17:49:54 +0100 Subject: [PATCH] document.selection is undefined in IE11 IE11 replaced document.selection by window.getSelection, which breaks dialogs in WikiEditor, because document.selection.createRange was accessed without check. Inserting this check unbreaks the dialogs. Bug: 57489 Change-Id: I70d49fb43bbf7602f43e9a8086ecd32027cb6d6f --- modules/jquery.wikiEditor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/jquery.wikiEditor.js b/modules/jquery.wikiEditor.js index 460203ff..bfcc73d5 100644 --- a/modules/jquery.wikiEditor.js +++ b/modules/jquery.wikiEditor.js @@ -249,7 +249,7 @@ if ( !context || typeof context === 'undefined' ) { 'oldDelayedHTML': null, // The previous selection of the iframe, stored to detect whether the selection has changed 'oldDelayedSel': null, - // Saved selection state for IE + // Saved selection state for old IE (<=10) 'savedSelection': null, // Stack of states in { html: [string] } form 'history': [], @@ -459,17 +459,17 @@ if ( !context || typeof context === 'undefined' ) { }, /** - * Save text selection for IE + * Save text selection for old IE (<=10) */ saveSelection: function () { - if ( $.client.profile().name === 'msie' ) { + if ( $.client.profile().name === 'msie' && document.selection && document.selection.createRange ) { context.$textarea.focus(); context.savedSelection = document.selection.createRange(); } }, /** - * Restore text selection for IE + * Restore text selection for old IE (<=10) */ restoreSelection: function () { if ( $.client.profile().name === 'msie' && context.savedSelection !== null ) {