Make WordPress Core

Changeset 42442 for branches/4.9


Ignore:
Timestamp:
01/13/2018 11:27:54 AM (7 years ago)
Author:
azaozz
Message:

Merged revision 42430 from trunk:
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 4.9.2.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/js/editor.js

    r42184 r42442  
    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.