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

See #33300.

git-svn-id: https://develop.svn.wordpress.org/trunk@36720 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2016-02-26 01:55:33 +00:00
parent 37fda5a8b9
commit 825e2e45fe
1 changed files with 6 additions and 2 deletions

View File

@ -235,7 +235,7 @@
start = rng.startContainer,
node = firstTextNode( start ),
i = enterPatterns.length,
text, pattern;
text, pattern, parent;
if ( ! node ) {
return;
@ -273,7 +273,11 @@
editor.formatter.apply( pattern.format, {}, node );
node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) );
} else if ( pattern.element ) {
editor.getBody().replaceChild( document.createElement( pattern.element ), node.parentNode );
parent = node.parentNode && node.parentNode.parentNode;
if ( parent ) {
parent.replaceChild( document.createElement( pattern.element ), node.parentNode );
}
}
} );