Commit ccc7822c authored by catch's avatar catch

Issue #1198904 by jox, das-peter: Fixed drupal_load_stylsheet() does not...

Issue #1198904 by jox, das-peter: Fixed drupal_load_stylsheet() does not comply with standards when using @import.
parent 6f1e2523
......@@ -96,17 +96,23 @@ public function loadFile($file, $optimize = NULL, $reset_basepath = TRUE) {
if ($basepath && !file_uri_scheme($file)) {
$file = $basepath . '/' . $file;
}
// Store the parent base path to restore it later.
$parent_base_path = $basepath;
// Set the current base path to process possible child imports.
$basepath = dirname($file);
// Load the CSS stylesheet. We suppress errors because themes may specify
// stylesheets in their .info.yml file that don't exist in the theme's path,
// but are merely there to disable certain module CSS files.
$content = '';
if ($contents = @file_get_contents($file)) {
// Return the processed stylesheet.
return $this->processCss($contents, $_optimize);
$content = $this->processCss($contents, $_optimize);
}
return '';
// Restore the parent base path as the file and its childen are processed.
$basepath = $parent_base_path;
return $content;
}
/**
......
......@@ -169,7 +169,23 @@ function testOptimizeProvider() {
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
),
'#home body { position: fixed; }',
)
),
// File in subfolder. Tests:
// - CSS import path is properly interpreted. (https://drupal.org/node/1198904)
5 => array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
'preprocess' => TRUE,
'data' => $path . 'css_subfolder/css_input_with_import.css',
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'basename' => 'css_input_with_import.css',
),
str_replace('url(../images/icon.png)', 'url(' . file_create_url($path . 'images/icon.png') . ')', file_get_contents($path . 'css_subfolder/css_input_with_import.css.optimized.css')),
),
);
}
......
@import "../import1.css";
@import "../import2.css";
body {
margin: 0;
padding: 0;
background: #edf5fa;
font: 76%/170% Verdana, sans-serif;
color: #494949;
}
.this .is .a .test {
font: 1em/100% Verdana, sans-serif;
color: #494949;
}
.this
.is
.a
.test {
font: 1em/100% Verdana, sans-serif;
color: #494949;
}
textarea, select {
font: 1em/160% Verdana, sans-serif;
color: #494949;
}
ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(../images/icon.png);}
p,select{font:1em/160% Verdana,sans-serif;color:#494949;}
body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
.is
.a
.test{font:1em/100% Verdana,sans-serif;color:#494949;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment