#265719 by kkaefer, JacobSingh, ksenzee, and rfay: Fixed CSS aggregator produces invalid code and directory names for @import files which breaks IE (with tests).
parent
1407c81632
commit
436ddca9fb
|
@ -3497,8 +3497,17 @@ function _drupal_load_stylesheet($matches) {
|
|||
$filename = $matches[1];
|
||||
// Load the imported stylesheet and replace @import commands in there as well.
|
||||
$file = drupal_load_stylesheet($filename);
|
||||
// Alter all url() paths, but not external.
|
||||
return preg_replace('/url\(([\'"]?)(?![a-z]+:)([^\'")]+)[\'"]?\)?;/i', 'url(\1' . dirname($filename) . '/', $file);
|
||||
|
||||
// Determine the file's directory.
|
||||
$directory = dirname($filename);
|
||||
// If the file is in the current directory, make sure '.' doesn't appear in
|
||||
// the url() path.
|
||||
$directory = $directory == '.' ? '' : $directory .'/';
|
||||
|
||||
// Alter all internal url() paths. Leave external paths alone. We don't need
|
||||
// to normalize absolute paths here (i.e. remove folder/... segments) because
|
||||
// that will be done later.
|
||||
return preg_replace('/url\s*\(([\'"]?)(?![a-z]+:|\/+)/i', 'url(\1'. $directory, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
|
||||
@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;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
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;}
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
ul, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
||||
.ui-icon{background-image: url(images/icon.png);}
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
p, select {
|
||||
font: 1em/160% Verdana, sans-serif;
|
||||
color: #494949;
|
||||
}
|
|
@ -757,7 +757,9 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
|
|||
*
|
||||
* This can be enhanced by adding additional CSS files with variant test cases.
|
||||
* Currently, this is specifically testing to make sure that whitespace
|
||||
* is treated with adequate respect (not arbitrarily removing linefeeds).
|
||||
* is treated with adequate respect (see http://drupal.org/node/472820) and
|
||||
* that image paths in imported files are preserved (see
|
||||
* http://drupal.org/node/265719).
|
||||
*/
|
||||
function testLoadCssBasic() {
|
||||
// Array of files to test living in 'simpletest/files/css_test_files/'.
|
||||
|
@ -766,6 +768,7 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
|
|||
// - Optimized expected content: name.css.optimized.css
|
||||
$testfiles = array(
|
||||
'css_input_without_import.css',
|
||||
'css_input_with_import.css'
|
||||
);
|
||||
$path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
|
||||
foreach ($testfiles as $file) {
|
||||
|
|
Loading…
Reference in New Issue