Only @import rules at top of aggregated stylesheets should be resolved.
E.g.
@import url(style1.css);
/* comment */
@import url(style2.css);
body {
color: red;
}
@import url(style3.css);
In this case only style1.css and style2.css should be resolved.
Comments
Comment #1
casey commentedFor more info see: http://www.w3.org/TR/REC-CSS2/cascade.html#at-import
This issue is not very urgent as long as modules have valid stylesheets without @import rules that aren't at the top.
Comment #2
casey commentedNote that currently also @import rules are resolved that occur in comments. e.g.
Result of CSS aggregation:
Comment #3
casey commentedComment #4
wim leersNow that #352951: Make JS & CSS Preprocessing Pluggable has landed, along with better tests for CSS aggregation/minification, it should be a whole lot easier to do this. See #2014851: Drupal CSS preprocessing breaks protocol-relative paths for an example.
Comment #5
dawehnerComment #14
johnalbinThe latest spec for CSS @import rules is the CSS Cascade Level 4. It says:
Now the issue description says:
But, of course, the CSS spec says nothing about whether Drupal should maintain valid URLs in invalid @import statements. Since we are moving files around, it makes sense for us to fix the URLs that we would otherwise be breaking, even if those statements are later ignored by browsers.
What is the actual expected behavior that is broken? I don't see any harm in resolving URLs in invalid @import statements. In fact, it would take more code to stop us from resolving these @import statements. Plus, if the aggregation process is pluggable, some contrib plugin could decide it wants to act on those invalid @import and it would be nice if core continued to ensure the URLs were valid inside the @import statement.
I'm tempted to close this with "won't fix" but I'll see if someone else has other thoughts.
Comment #15
darvanenI think the problem is that when combined with #646246: Only move non-resolved @import rules to top of aggregate stylesheet when also at top in own stylesheet this causes rules that would otherwise not be used by a browser come into play.
I agree that resolving URLs as we move files around in itself isn't a problem, I'm going to close this as a duplicate rather than "won't fix" to indicate it's part of the same issue.
Comment #16
darvanen