Fix/move charset top #70
Open
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.
@charset
must be on the first line of the concatenated file. However, the current code checks if@charset
is already at position0
(at the very beginning of the file). Only if@charset
is 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@charset
is present anywhere in $buf. Then it deletes the instance of@charset
from$buf
before the existing code adds the@charset
to the beginning of $buf. Otherwise, we end up with multiple@charset
declarations 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!