-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Handle closing parenthesis within data url in transform-styles (#16408) #17146
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
packages/block-editor/src/utils/transform-styles/test/__snapshots__/index.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CSS parse Should handle closing parenthesis within url 1`] = ` | ||
Object { | ||
"stylesheet": Object { | ||
"parsingErrors": Array [], | ||
"rules": Array [ | ||
Object { | ||
"declarations": Array [ | ||
Object { | ||
"position": Position { | ||
"end": Object { | ||
"column": 17, | ||
"line": 1, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 6, | ||
"line": 1, | ||
}, | ||
}, | ||
"property": "b", | ||
"type": "declaration", | ||
"value": "url(\\")\\")", | ||
}, | ||
Object { | ||
"position": Position { | ||
"end": Object { | ||
"column": 31, | ||
"line": 1, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 19, | ||
"line": 1, | ||
}, | ||
}, | ||
"property": "d", | ||
"type": "declaration", | ||
"value": "url(\\";a\\")", | ||
}, | ||
], | ||
"position": Position { | ||
"end": Object { | ||
"column": 34, | ||
"line": 1, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 1, | ||
"line": 1, | ||
}, | ||
}, | ||
"selectors": Array [ | ||
".a", | ||
], | ||
"type": "rule", | ||
}, | ||
], | ||
"source": undefined, | ||
}, | ||
"type": "stylesheet", | ||
} | ||
`; | ||
|
||
exports[`CSS parse Should handle urls without quotes 1`] = ` | ||
Object { | ||
"stylesheet": Object { | ||
"parsingErrors": Array [], | ||
"rules": Array [ | ||
Object { | ||
"declarations": Array [ | ||
Object { | ||
"position": Position { | ||
"end": Object { | ||
"column": 217, | ||
"line": 2, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 4, | ||
"line": 2, | ||
}, | ||
}, | ||
"property": "background-image", | ||
"type": "declaration", | ||
"value": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEBAMAAABb34NNAAAAFVBMVEXyrmHqcBDtdQ3pcRHcbRkAAAD/uSmYi/+cAAAABnRSTlORbFE2DwAwkbURAAAAEUlEQVQI12MIEmEwSwAiIAMAC/AB+fq6WIgAAAAASUVORK5CYII=)", | ||
}, | ||
Object { | ||
"position": Position { | ||
"end": Object { | ||
"column": 3, | ||
"line": 4, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 4, | ||
"line": 3, | ||
}, | ||
}, | ||
"property": "background-repeat", | ||
"type": "declaration", | ||
"value": "no-repeat", | ||
}, | ||
], | ||
"position": Position { | ||
"end": Object { | ||
"column": 4, | ||
"line": 4, | ||
}, | ||
"source": undefined, | ||
"start": Object { | ||
"column": 1, | ||
"line": 1, | ||
}, | ||
}, | ||
"selectors": Array [ | ||
".a", | ||
], | ||
"type": "rule", | ||
}, | ||
], | ||
"source": undefined, | ||
}, | ||
"type": "stylesheet", | ||
} | ||
`; | ||
|
||
exports[`CSS traverse Should traverse the CSS 1`] = ` | ||
"namespace h1 { | ||
color: red; | ||
}" | ||
`; |
7 changes: 0 additions & 7 deletions
7
packages/block-editor/src/utils/transform-styles/test/__snapshots__/traverse.js.snap
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
packages/block-editor/src/utils/transform-styles/test/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||
/** | ||||||
* Internal dependencies | ||||||
*/ | ||||||
import traverse from '../traverse'; | ||||||
import parse from '../ast/parse'; | ||||||
|
||||||
describe( 'CSS traverse', () => { | ||||||
it( 'Should traverse the CSS', () => { | ||||||
const input = `h1 { color: red; }`; | ||||||
const output = traverse( input, ( node ) => { | ||||||
if ( node.type === 'rule' ) { | ||||||
return { | ||||||
...node, | ||||||
selectors: node.selectors.map( | ||||||
( selector ) => 'namespace ' + selector | ||||||
), | ||||||
}; | ||||||
} | ||||||
|
||||||
return node; | ||||||
} ); | ||||||
|
||||||
expect( output ).toMatchSnapshot(); | ||||||
} ); | ||||||
} ); | ||||||
|
||||||
describe( 'CSS parse', () => { | ||||||
it( 'Should handle closing parenthesis within url', () => { | ||||||
const input = `.a { b: url(")"); d: url(";a"); }`; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String interpolation isn't necessary.
Suggested change
|
||||||
const output = parse( input ); | ||||||
|
||||||
expect( output ).toMatchSnapshot(); | ||||||
} ); | ||||||
|
||||||
it( 'Should handle urls without quotes', () => { | ||||||
const input = `.a { | ||||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEBAMAAABb34NNAAAAFVBMVEXyrmHqcBDtdQ3pcRHcbRkAAAD/uSmYi/+cAAAABnRSTlORbFE2DwAwkbURAAAAEUlEQVQI12MIEmEwSwAiIAMAC/AB+fq6WIgAAAAASUVORK5CYII=); | ||||||
background-repeat: no-repeat | ||||||
}`; | ||||||
const output = parse( input ); | ||||||
|
||||||
expect( output ).toMatchSnapshot(); | ||||||
} ); | ||||||
} ); |
24 changes: 0 additions & 24 deletions
24
packages/block-editor/src/utils/transform-styles/test/traverse.js
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's move the
describe( 'CSS traverse' )
back intotest/traverse.js
and put thedescribe( 'CSS parse' )
into a newtest/parse.js
file.