Make WordPress Core

Changeset 36720


Ignore:
Timestamp:
02/26/2016 01:55:33 AM (9 years ago)
Author:
azaozz
Message:

TinyMCE textpattern: fix error when inserting <hr> if the new paragraph is not direct child of the body.

See #33300.

File:
1 edited

Legend:

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

    r36719 r36720  
    236236                node = firstTextNode( start ),
    237237                i = enterPatterns.length,
    238                 text, pattern;
     238                text, pattern, parent;
    239239
    240240            if ( ! node ) {
     
    274274                        node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) );
    275275                    } else if ( pattern.element ) {
    276                         editor.getBody().replaceChild( document.createElement( pattern.element ), node.parentNode );
     276                        parent = node.parentNode && node.parentNode.parentNode;
     277
     278                        if ( parent ) {
     279                            parent.replaceChild( document.createElement( pattern.element ), node.parentNode );
     280                        }
    277281                    }
    278282                } );
Note: See TracChangeset for help on using the changeset viewer.