Open
Conversation
…e_output Otherwise we end up with multiple @charset declarations
sathyapulse
reviewed
Sep 23, 2022
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@charsetmust be on the first line of the concatenated file. However, the current code checks if@charsetis already at position0(at the very beginning of the file). Only if@charsetis already at the beginning will the code then attempt to move it to the beginning (where it already is located).This PR changes
if ( 0 === strpos( $buf, '@charset' ) ) {tofalse !== strpos( $buf, '@charset' )so that it checks if@charsetis present anywhere in $buf. Then it deletes the instance of@charsetfrom$bufbefore the existing code adds the@charsetto the beginning of $buf. Otherwise, we end up with multiple@charsetdeclarations in the concatenated file. There may be better ways to avoid this.The following is an example of how I tested this:
style1.css:
style2.css:
With the current code the code the concatenated file looks like:
Notice the current code does move
@charset, but to the top of the contents of the original file, not the top of the concatenated file.With the commits in this PR the concatenated file would like like:
With my first commit but without my second commit (86331aa) it looked like:
Hope this is helpful!