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.
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
Retain the same specificity for non iframed selectors #64534
Retain the same specificity for non iframed selectors #64534
Changes from 15 commits
121ab38
63daf74
fa01d08
ca755ce
e73b3ae
36b6fb4
05282b1
5b02106
8e94cb1
cbd97fc
e65d65a
b271945
a9f8b10
17ac050
93455f8
25bfa9d
6b43b57
1cf8d6c
06051c3
53ee8cf
2fae7f6
8943a84
cef751e
170a313
5292a44
65071fd
88e328e
9ded287
15f00de
f6a8476
69db0cb
534a8b5
b8db01a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Would it be better to leave this as it is, covering different specificities in the selector list, and just update the output?
To me, the original input covered the scenario when the plugin detects that it does need to prefix something and then ensures it doesn't go overboard resulting in a double prefix.
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 liked being able to make the test
expect( output ).toEqual( [ input ] )
, but I've updated it in 6b43b57 to be as it was before (though without snapshots)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.
Would it be worth a comment here explaining why this is needed?
My understanding of the old plugin was that it ignored all selectors already starting with the prefix. This one seems to only do a simple comparison between the selectors in
exclude
and so requires this double handling. Is that correct?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.
The 'should not double wrap selectors' was failing when I switched to the new library. You're right that the
ignoredSelectors
seems to be where the old library works differently to the new one. We've been using the string'.editor-styles-wrapper'
as an ignored selector. With the old library it uses something akin toselector.includes( ignoredSelector )
to check if it should be ignored, whereas the new library is more likeselector === ignoredSelector
. Both also support regular expressions, but we weren't using that.I think this will be an issue as
transformStyles
is a public API, soignoredSelectors
should work the same as before. 🤔Probably the best bet would be to replicate how the old library works in the callback rather than the way I've done it using
replaceDoublePrefix
😄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.
Done in 6b43b57
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 haven't had a chance to look deeply at the code after the latest updates but did you account for the fact the old plugin allows regex in those ignored selectors?
Here's a snippet from the plugin's readme.
As noted in my earlier comment, this new plugin appears to do a direct comparison of selectors. Take that with a grain of salt but something to double all the same.
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.
Yep, the pseudocode is
selector.match( ignoredSelector )
, andmatch
which will work for both plain strings and regexes.edit: pushed a commit to make sure there's test coverage for regex ignored selectors.
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.
Nice. Appreciate the extra test coverage there 👌