From 5e524200b4fd334971ca0ba7c3c57d60a8d89a73 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 8 Jan 2018 20:20:00 +0000 Subject: [PATCH] Editor: ensure there is a selection before getting the caret position. Fixes a bug in Firefox when there is no selection for a hidden element. Props johnschulz, azaozz. Fixes #43012 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@42430 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/editor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index 6010e8f7f8..103d6bbf96 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -695,10 +695,10 @@ window.wp = window.wp || {}; */ function findBookmarkedPosition( editor ) { // Get the TinyMCE `window` reference, since we need to access the raw selection. - var TinyMCEWIndow = editor.getWin(), - selection = TinyMCEWIndow.getSelection(); + var TinyMCEWindow = editor.getWin(), + selection = TinyMCEWindow.getSelection(); - if ( selection.rangeCount <= 0 ) { + if ( ! selection || selection.rangeCount < 1 ) { // no selection, no need to continue. return; }