Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blocks/api/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function parseWithTinyMCE( content ) {
flushContentBetweenBlocks();

let currentNode = tree.firstChild;
do {
while ( currentNode ) {
if ( currentNode.name === 'wp-block' ) {
// Set node type to document fragment so that the TinyMCE
// serializer doesn't output its markup
Expand Down Expand Up @@ -208,7 +208,7 @@ export function parseWithTinyMCE( content ) {
currentNode = currentNode.next;
contentBetweenBlocks.append( toAppend );
}
} while ( currentNode );
}

flushContentBetweenBlocks();

Expand Down
6 changes: 6 additions & 0 deletions blocks/api/test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ describe( 'block parser', () => {
expect( parsed[ 0 ].uid ).to.be.a( 'string' );
} );

it( 'should parse empty post content', () => {
const parsed = parse( '' );

expect( parsed ).to.eql( [] );
} );

it( 'should parse the post content, ignoring unknown blocks', () => {
registerBlock( 'core/test-block', {
attributes: function( rawContent ) {
Expand Down