diff --git a/packages/block-library/src/list/utils.js b/packages/block-library/src/list/utils.js index 9603c1d08e0f0..a80ce456e29ab 100644 --- a/packages/block-library/src/list/utils.js +++ b/packages/block-library/src/list/utils.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { createBlock } from '@wordpress/blocks'; +import { createBlock, rawHandler } from '@wordpress/blocks'; export function createListBlockFromDOMElement( listElement ) { const listAttributes = { @@ -70,15 +70,7 @@ export function migrateToListV2( attributes ) { list.setAttribute( 'type', type ); } - const listBlock = createListBlockFromDOMElement( list ); + const [ listBlock ] = rawHandler( { HTML: list.outerHTML } ); - const { values: omittedValues, ...restAttributes } = attributes; - - return [ - { - ...restAttributes, - ...listBlock.attributes, - }, - listBlock.innerBlocks, - ]; + return [ listBlock.attributes, listBlock.innerBlocks ]; } diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.html b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.html new file mode 100644 index 0000000000000..71170bde67a88 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.html @@ -0,0 +1,3 @@ + + + diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.json b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.json new file mode 100644 index 0000000000000..0e5c001e4e036 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.json @@ -0,0 +1,112 @@ +[ + { + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "" + }, + "innerBlocks": [ + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [ + { + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "" + }, + "innerBlocks": [ + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [ + { + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "" + }, + "innerBlocks": [ + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [] + } + ] + } + ] + }, + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [ + { + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "" + }, + "innerBlocks": [ + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [] + } + ] + } + ] + }, + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [ + { + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "" + }, + "innerBlocks": [ + { + "name": "core/list-item", + "isValid": true, + "attributes": { + "content": "Item" + }, + "innerBlocks": [] + } + ] + } + ] + } + ] + } + ] + } + ] + } +] diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.parsed.json b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.parsed.json new file mode 100644 index 0000000000000..11b05c91870a8 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.parsed.json @@ -0,0 +1,11 @@ +[ + { + "blockName": "core/list", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n", + "innerContent": [ + "\n\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.serialized.html b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.serialized.html new file mode 100644 index 0000000000000..61e33d3dc0e15 --- /dev/null +++ b/test/integration/fixtures/blocks/core__list__deprecated-v1-nested.serialized.html @@ -0,0 +1,29 @@ + + +