Make WordPress Core

Changeset 32832


Ignore:
Timestamp:
06/18/2015 11:33:11 AM (10 years ago)
Author:
iseulde
Message:

TinyMCE: wptextpattern: fix issue that removes content

  • If the resulting text node is empty, don't remove all the content from the paragraph.
  • If there's an empty text node at the start of the paragraph, ignore it and consider the next node to be the start.

See #31441.

Location:
trunk
Files:
2 edited

Legend:

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

    r32795 r32832  
    8888            }
    8989
     90            if ( ! child.nodeValue ) {
     91                child = child.nextSibling;
     92            }
     93
    9094            if ( child !== node ) {
    9195                return;
     
    110114
    111115                editor.undoManager.transact( function() {
     116                    var $$parent;
     117
    112118                    if ( replace ) {
    113119                        $$( node ).replaceWith( document.createTextNode( replace ) );
    114120                    } else  {
    115                         $$( node.parentNode ).empty().append( '<br>' );
     121                        $$parent = $$( node.parentNode );
     122
     123                        $$( node ).remove();
     124
     125                        if ( ! $$parent.html() ) {
     126                            $$parent.append( '<br>' );
     127                        }
    116128                    }
    117129
  • trunk/tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js

    r32706 r32832  
    7878    } );
    7979
    80     QUnit.test( 'Ordered list with content.', function( assert ) {
     80    QUnit.test( 'Ordered list with content. (1)', function( assert ) {
    8181        editor.setContent( '<p><strong>test</strong></p>' );
    8282        editor.selection.setCursorLocation();
     83
     84        type( '* ', function() {
     85            assert.equal( editor.getContent(), '<ul>\n<li><strong>test</strong></li>\n</ul>' );
     86        }, assert.async() );
     87    } );
     88
     89    QUnit.test( 'Ordered list with content. (2)', function( assert ) {
     90        editor.setContent( '<p><strong>test</strong></p>' );
     91        editor.selection.setCursorLocation( editor.$( 'p' )[0], 0 );
    8392
    8493        type( '* ', function() {
Note: See TracChangeset for help on using the changeset viewer.