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
This commit is contained in:
Andrew Ozz 2018-01-08 20:20:00 +00:00
parent 9cf7385eb3
commit 5e524200b4
1 changed files with 3 additions and 3 deletions

View File

@ -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;
}