Skip to content

Commit

Permalink
MDL-33825 css_optimiser: Fixed bug where !important was being lost fo…
Browse files Browse the repository at this point in the history
…r advanced background styles
  • Loading branch information
Sam Hemelryk committed Jun 19, 2012
1 parent f4a9bf6 commit 2395a75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/csslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3845,7 +3845,11 @@ public static function init($value) {
} else if ($attachment === self::NULL_VALUE && in_array($bit, $attachments)) {
$attachment = $bit;
} else if ($bit !== '') {
$return[] = css_style_background_advanced::init($bit);
$advanced = css_style_background_advanced::init($bit);
if ($important) {
$advanced->set_important();
}
$return[] = $advanced;
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/tests/csslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ public function test_background() {

$css = '#filesskin .yui3-widget-hd{background:#CCC;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC));background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC);}';
$this->assertEquals($css, $optimiser->process($css));

$css = '.userenrolment{background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}';
$this->assertEquals($css, $optimiser->process($css));

$css = '.userenrolment{background:#CCC !important;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC)) !important;background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}';
$this->assertEquals($css, $optimiser->process($css));

$cssin = '.userenrolment{background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}.userenrolment {background: #CCCCCC!important;background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC))!important;}';
$cssout = '.userenrolment{background:#CCC !important;background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC)) !important;}';
$this->assertEquals($cssout, $optimiser->process($cssin));
}

/**
Expand Down

0 comments on commit 2395a75

Please sign in to comment.