Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!9361
Issue
#3470829
: add @import layer support
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3470829
: add @import layer support
issue/drupal-3470829:3470829-support-for-css
into
11.0.x
Overview
0
Commits
1
Pipelines
1
Changes
1
Open
woldtwerk
requested to merge
issue/drupal-3470829:3470829-support-for-css
into
11.0.x
9 months ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
Closes
#3470829
0
0
Merge request reports
Compare
11.0.x
11.0.x (HEAD)
and
latest version
latest version
08e6580e
1 commit,
9 months ago
1 file
+
8
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/lib/Drupal/Core/Asset/CssOptimizer.php
+
8
−
1
Options
@@ -189,6 +189,13 @@ protected function loadNestedFile($matches) {
// well.
$file
=
$this
->
loadFile
(
$filename
,
NULL
,
FALSE
);
// Get CSS layer if it exists.
$layer
=
isset
(
$matches
[
2
])
?
str_replace
([
'layer('
,
')'
],
''
,
$matches
[
2
])
:
FALSE
;
if
(
$layer
)
{
$file
=
"@layer
$layer
{
$file
}"
;
}
// Determine the file's directory.
$directory
=
dirname
(
$filename
);
// If the file is in the current directory, make sure '.' doesn't appear in
@@ -262,7 +269,7 @@ protected function processCss($contents, $optimize = FALSE) {
// This happens recursively but omits external files and local files
// with supports- or media-query qualifiers, as those are conditionally
// loaded depending on the user agent.
$contents
=
preg_replace_callback
(
'/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/'
,
[
$this
,
'loadNestedFile'
],
$contents
);
$contents
=
preg_replace_callback
(
'/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*
(layer\([a-z]+\))?\s*
;/'
,
[
$this
,
'loadNestedFile'
],
$contents
);
return
$contents
;
}
Loading