Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19358d7
Post Featured Image: Fix height/scale overwriting border inline style…
aaronrobertshaw Sep 19, 2022
cfe41d8
Fluid typography: add font size constraints (#44993)
ramonjd Oct 18, 2022
c1d0fb8
Allow direct selection of nested Page List block by avoiding dual ren…
getdave Oct 20, 2022
27fc28f
Fix popover deprecations (#45195)
talldan Oct 26, 2022
d1e989b
Components: Refactor `ColorPalette` tests to `@testing-library/react`…
tyxla Sep 15, 2022
b7c87a9
Fix changelog
Mamaduka Nov 10, 2022
a69ad93
Convert the `ColorPalette` component to TypeScript (#44632)
kienstra Oct 26, 2022
1d6e86f
List v2: fix migration when nested list is invalid (#44822)
ellatrix Oct 28, 2022
5df9d42
Link to homeUrl from site editor view menu. (#45475)
peterwilsoncc Nov 3, 2022
86755ae
Table Block: Apply borders and padding on both front end and editor (…
mikachan Nov 4, 2022
2406bb9
Change the order of the pseudo-states in the pseudo selectors array (…
mikachan Nov 7, 2022
78717bd
Do not look for block variants, if not supporting block-templates (#4…
spacedmonkey Nov 8, 2022
bcff52e
Restore the empty paragraph inserter (#45542)
youknowriad Nov 9, 2022
d6485c6
Cover: Avoid content loss when the templateLock value is all or conte…
Mamaduka Nov 10, 2022
035afba
List: disable nested list drop zone so dropping list items works (#45…
ellatrix Nov 10, 2022
6941ad1
Fix cherry-picking error
Mamaduka Nov 10, 2022
67b7b5e
Switch background color to text color on block separator (#44943)
cbravobernal Nov 2, 2022
3b4797b
Fix performance tests
Mamaduka Nov 10, 2022
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
Prev Previous commit
Next Next commit
List v2: fix migration when nested list is invalid (#44822)
* List v2: fix migration when nested list is invalid

* Reduce test case
  • Loading branch information
ellatrix authored and Mamaduka committed Nov 10, 2022
commit 1d6e86f5985700aee899f74e0aebfe09ca97374b
14 changes: 3 additions & 11 deletions packages/block-library/src/list/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
import { createBlock, rawHandler } from '@wordpress/blocks';

export function createListBlockFromDOMElement( listElement ) {
const listAttributes = {
Expand Down Expand Up @@ -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 ];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:list -->
<ul><li><strong>Item</strong><ul><li><strong>Item</strong><ul><li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li></ul></li></ul></li></ul>
<!-- /wp:list -->
112 changes: 112 additions & 0 deletions test/integration/fixtures/blocks/core__list__deprecated-v1-nested.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": false,
"values": ""
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<strong>Item</strong>"
},
"innerBlocks": [
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": false,
"values": ""
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<strong>Item</strong>"
},
"innerBlocks": [
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": false,
"values": ""
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a>"
},
"innerBlocks": []
}
]
}
]
},
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<strong>Item</strong>"
},
"innerBlocks": [
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": false,
"values": ""
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a>"
},
"innerBlocks": []
}
]
}
]
},
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<strong>Item</strong>"
},
"innerBlocks": [
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": false,
"values": ""
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "<a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a>"
},
"innerBlocks": []
}
]
}
]
}
]
}
]
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"blockName": "core/list",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n<ul><li><strong>Item</strong><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul></li></ul>\n",
"innerContent": [
"\n<ul><li><strong>Item</strong><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul><ul><li><strong>Item</strong><ul><li><a rel=\"noreferrer noopener\" href=\"#\" target=\"_blank\">Item</a></li></ul></li></ul></li></ul>\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- wp:list -->
<ul><!-- wp:list-item -->
<li><strong>Item</strong><!-- wp:list -->
<ul><!-- wp:list-item -->
<li><strong>Item</strong><!-- wp:list -->
<ul><!-- wp:list-item -->
<li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><strong>Item</strong><!-- wp:list -->
<ul><!-- wp:list-item -->
<li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><strong>Item</strong><!-- wp:list -->
<ul><!-- wp:list-item -->
<li><a rel="noreferrer noopener" href="#" target="_blank">Item</a></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->