Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current version of \Drupal\Core\Asset\CssCollectionRenderer
can in theory be extended by a contrib module that wants to do something special with it, but it's not very useful, because all the logic is dumped within the render
function, so the only option one has is simply rewriting this function.
The attached patch changes this:
- The logic for rendering a LINK tag and rendering a STYLE tag with imports is moved to separate functions
- The logic for grouping the stylesheets in groups for IE is moved to separate function.
- The logic for generating an URL with a cache busting query string is moved a separate function.
The patch also changes a few things in Unit test.
- Because the query string value from the state is statically cached, the class doesn't always call the state for this
- The new logic creates a link tag for every single stylesheet, while the old logic created a style tag with an import statement if the stylesheet could in theory end up in a style tag but didn't because there were no other stylesheets after this with the same properties.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2862516-2.patch | 14.56 KB | Rolf van de Krol |
Comments
Comment #2
Rolf van de Krol CreditAttribution: Rolf van de Krol commentedComment #4
Rolf van de Krol CreditAttribution: Rolf van de Krol commented