Do not migrate declarations in <style>
blocks
#18057
Merged
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.
This PR improves the upgrade tool by making sure that we don't migrate CSS declarations in
<style>…</style>
blocks.We do this by making sure that:
We detect a declaration, the current heuristic is that the candidate is:
We are in a
<style>…</style>
blockThe reason we have these 2 checks is because just relying on the first heuristic alone, also means that we will not be migrating keys in JS objects, because they typically follow the same structure:
Another important thing to note is that we can't just ignore anything in between
<style>…</style>
blocks, because you could still be using@apply
that we do want to migrate.Last but not least, the first heuristics is not perfect either. If you are writing minified CSS then this will likely fail if there is no whitespace around the candidate.
But my current assumption is that nobody should be writing minified CSS, and minified CSS will very likely be generated and gitignored. In either situation, replacements in minified CSS will not be any worse than it is today.
I'm open to suggestions for better heuristics.
Test plan
@apply
and don't migrate theflex-shrink: 0;
declaration.Fixes: #17975