WordPress.org

Make WordPress Core

Changeset 29126


Ignore:
Timestamp:
07/12/2014 10:50:19 PM (4 years ago)
Author:
azaozz
Message:

TinyMCE wpView: fix selecting views on click, part props avryl, see #28595

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r29049 r29126  
    1313
    1414    function getView( node ) {
    15         // Doing this directly is about 40% faster
     15        return getParent( node, 'wpview-wrap' );
     16    }
     17
     18    /**
     19     * Returns the node or a parent of the node that has the passed className.
     20     * Doing this directly is about 40% faster
     21     */
     22    function getParent( node, className ) {
    1623        while ( node && node.parentNode ) {
    17             if ( node.className && (' ' + node.className + ' ').indexOf(' wpview-wrap ') !== -1 ) {
     24            if ( node.className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1 ) {
    1825                return node;
    1926            }
     
    624631                // If the cursor lands anywhere else in the view, set the cursor before it.
    625632                // Only try this once to prevent a loop. (You never know.)
    626                 } else if ( className !== 'wpview-clipboard' && ! setViewCursorTries ) {
     633                } else if ( ! getParent( event.element, 'wpview-body' ) && ! setViewCursorTries ) {
    627634                    deselect();
    628635                    setViewCursorTries++;
Note: See TracChangeset for help on using the changeset viewer.