Make WordPress Core

Changeset 42430


Ignore:
Timestamp:
01/08/2018 08:20:00 PM (7 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/editor.js

    r42411 r42430  
    696696        function findBookmarkedPosition( editor ) {
    697697            // Get the TinyMCE `window` reference, since we need to access the raw selection.
    698             var TinyMCEWIndow = editor.getWin(),
    699                 selection = TinyMCEWIndow.getSelection();
    700 
    701             if ( selection.rangeCount <= 0 ) {
     698            var TinyMCEWindow = editor.getWin(),
     699                selection = TinyMCEWindow.getSelection();
     700
     701            if ( ! selection || selection.rangeCount < 1 ) {
    702702                // no selection, no need to continue.
    703703                return;
Note: See TracChangeset for help on using the changeset viewer.