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

Ignore style validation errors #37942

Closed
wants to merge 1 commit into from
Closed
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 packages/blocks/src/api/test/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ describe( 'validation', () => {
expect( isEqual ).toBe( true );
} );

it( 'returns false if not same style', () => {
it( 'returns true even if the style is different', () => {
const isEqual = isEqualAttributesOfName.style(
'background-image: url( "https://wordpress.org/img.png" ); color: red;',
"color: red; font-size: 13px; background-image: url('https://wordpress.org/img.png');"
);

expect( isEqual ).toBe( false );
expect( isEqual ).toBe( true );
} );
} );

Expand Down
6 changes: 2 additions & 4 deletions packages/blocks/src/api/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { Tokenizer } from 'simple-html-tokenizer';
import { identity, xor, fromPairs, isEqual, includes, stubTrue } from 'lodash';
import { identity, xor, fromPairs, includes, stubTrue } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -407,9 +407,7 @@ export const isEqualAttributesOfName = {
...[ actual, expected ].map( getTextPiecesSplitOnWhitespace )
).length;
},
style: ( actual, expected ) => {
return isEqual( ...[ actual, expected ].map( getStyleProperties ) );
},
style: () => true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
style: () => true,
// Minor differences in style attributes should not cause blocks to be considered invalid.
// Consider different `style` attributes to be equivalent (if not strictly equal).
// See: https://github.com/WordPress/gutenberg/issues/37851
style: () => true,

This change seems significant enough to warrant an inline comment.

// For each boolean attribute, mere presence of attribute in both is enough
// to assume equivalence.
...fromPairs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"attributes": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"id": 35,
"isRepeated": false,
"hasParallax": false,
"dimRatio": 50,
"backgroundType": "image",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.