Merge branch 'wip-MDL-33825-m23' of git://github.com/samhemelryk/moodle
authorAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 08:50:54 +0000 (16:50 +0800)
committerAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 08:50:54 +0000 (16:50 +0800)
lib/csslib.php
lib/tests/csslib_test.php

index 3032433..2408e38 100644 (file)
@@ -3845,7 +3845,11 @@ class css_style_background extends css_style {
                 } 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;
                 }
             }
         }
index c5f1223..f00a88f 100644 (file)
@@ -213,6 +213,16 @@ class css_optimiser_testcase extends advanced_testcase {
 
         $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));
     }
 
     /**