Skip to content

Commit

Permalink
TinyMCE: Remove container assignment hack (#8465)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Aug 6, 2018
1 parent 4fd5c20 commit 4c28bd0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/editor/src/components/rich-text/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ export default class TinyMCE extends Component {
return;
}

// This hack prevents TinyMCE from trying to remove the container node
// while cleaning for destroy, since removal is handled by React. It
// does so by substituting the container to be removed.
this.editor.container = document.createDocumentFragment();
this.editor.destroy();
delete this.editor;
}
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/specs/__snapshots__/rich-text.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adding blocks Should handle change in tag name gracefully 1`] = `
"<!-- wp:heading {\\"level\\":3} -->
<h3></h3>
<!-- /wp:heading -->"
`;
29 changes: 29 additions & 0 deletions test/e2e/specs/rich-text.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Internal dependencies
*/
import '../support/bootstrap';
import {
newPost,
newDesktopBrowserPage,
getEditedPostContent,
insertBlock,
} from '../support/utils';

describe( 'adding blocks', () => {
beforeEach( async () => {
await newDesktopBrowserPage();
await newPost();
} );

it( 'Should handle change in tag name gracefully', async () => {
// Regression test: The heading block changes the tag name of its
// RichText element. Historically this has been prone to breakage,
// specifically in destroying / reinitializing the TinyMCE instance.
//
// See: https://github.com/WordPress/gutenberg/issues/3091
await insertBlock( 'Heading' );
await page.click( '[aria-label="Heading 3"]' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit 4c28bd0

Please sign in to comment.