Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Add fixture for Column deprecation #26774

Merged
merged 1 commit into from
Nov 6, 2020
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
8 changes: 4 additions & 4 deletions packages/block-library/src/column/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const deprecated = [
max: 100,
},
},
isEligible( { width } ) {
return isFinite( width );
},
migrate( attributes ) {
return {
...attributes,
Expand All @@ -33,10 +36,7 @@ const deprecated = [
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
} );

let style;
if ( Number.isFinite( width ) ) {
style = { flexBasis: width + '%' };
}
const style = { flexBasis: width + '%' };

return (
<div className={ wrapperClasses } style={ style }>
Expand Down
10 changes: 10 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- wp:column {"width":33.33} -->
<div class="wp-block-column" style="flex-basis:33.33%">
<!-- wp:paragraph -->
<p>Column One, Paragraph One</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Column One, Paragraph Two</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:columns -->
35 changes: 35 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"clientId": "_clientId_0",
"name": "core/column",
"isValid": true,
"attributes": {
"width": "33.33%"
},
"innerBlocks": [
{
"clientId": "_clientId_0",
"name": "core/paragraph",
"isValid": true,
"attributes": {
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
},
{
"clientId": "_clientId_1",
"name": "core/paragraph",
"isValid": true,
"attributes": {
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
}
],
"originalContent": "<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t\n\t\n</div>"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"blockName": "core/column",
"attrs": {
"width": 33.33
},
"innerBlocks": [
{
"blockName": "core/paragraph",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<p>Column One, Paragraph One</p>\n\t",
"innerContent": [
"\n\t<p>Column One, Paragraph One</p>\n\t"
]
},
{
"blockName": "core/paragraph",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<p>Column One, Paragraph Two</p>\n\t",
"innerContent": [
"\n\t<p>Column One, Paragraph Two</p>\n\t"
]
}
],
"innerHTML": "\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t\n\t\n</div>\n",
"innerContent": [
"\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t",
null,
"\n\t",
null,
"\n</div>\n"
]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n",
"innerContent": [
"\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- wp:column {"width":"33.33%"} -->
<div class="wp-block-column" style="flex-basis:33.33%"><!-- wp:paragraph -->
<p>Column One, Paragraph One</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Column One, Paragraph Two</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->