Handle core blocks edge case and update test
This commit is contained in:
parent
fd851227de
commit
91669cfe52
|
@ -219,9 +219,16 @@ trait BlockContainerTrait {
|
|||
$name = $this->get_name();
|
||||
$attributes = $this->get_augmented_attributes();
|
||||
|
||||
$children = implode( "\n", $arr );
|
||||
$children = implode( '', $arr );
|
||||
|
||||
return '' !== $name ? get_comment_delimited_block_content( $name, $attributes, $children ) : $children;
|
||||
$content = '';
|
||||
if ( 'core/column' === $name ) {
|
||||
$content = '<div class="wp-block-column" />';
|
||||
} elseif ( 'core/columns' === $name ) {
|
||||
$content = '<div class="wp-block-columns" />';
|
||||
}
|
||||
|
||||
return '' !== $name ? get_comment_delimited_block_content( $name, $attributes, $content . $children ) : $children;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -713,6 +713,20 @@ class BlockTest extends WC_Unit_Test_Case {
|
|||
)
|
||||
);
|
||||
|
||||
$this->assertSame( '<!-- wp:test-block-name {"attr-1":"value-1","attr-2":"value-2","_templateBlockId":"test-block-id","_templateBlockOrder":10000,"_templateBlockHideConditions":[{"expression":"foo === bar"}],"_templateBlockDisableConditions":[{"expression":"test \u003e 100"}]} --><!-- wp:test-block-name-2 {"attr-3":"value-3","attr-4":"value-4","_templateBlockId":"test-block-id-2","_templateBlockOrder":10000} /-->' . "\n" . '<!-- wp:test-block-name-3 {"_templateBlockId":"test-block-id-3","_templateBlockOrder":10000} /--><!-- /wp:test-block-name -->', $template->get_comment_delimited_template() );
|
||||
$columns = $block->add_block(
|
||||
array(
|
||||
'id' => 'test-block-id-4',
|
||||
'blockName' => 'core/columns',
|
||||
)
|
||||
);
|
||||
|
||||
$columns->add_block(
|
||||
array(
|
||||
'id' => 'test-block-id-5',
|
||||
'blockName' => 'core/column',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( '<!-- wp:test-block-name {"attr-1":"value-1","attr-2":"value-2","_templateBlockId":"test-block-id","_templateBlockOrder":10000,"_templateBlockHideConditions":[{"expression":"foo === bar"}],"_templateBlockDisableConditions":[{"expression":"test \u003e 100"}]} --><!-- wp:test-block-name-2 {"attr-3":"value-3","attr-4":"value-4","_templateBlockId":"test-block-id-2","_templateBlockOrder":10000} /--><!-- wp:test-block-name-3 {"_templateBlockId":"test-block-id-3","_templateBlockOrder":10000} /--><!-- wp:columns {"_templateBlockId":"test-block-id-4","_templateBlockOrder":10000} --><div class="wp-block-columns" /><!-- wp:column {"_templateBlockId":"test-block-id-5","_templateBlockOrder":10000} --><div class="wp-block-column" /><!-- /wp:column --><!-- /wp:columns --><!-- /wp:test-block-name -->', $template->get_comment_delimited_template() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue