Fixed rules with !important incorrectly applied
authorAlexander Ebert <ebert@woltlab.com>
Sun, 24 Jan 2016 16:27:13 +0000 (17:27 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 24 Jan 2016 16:27:13 +0000 (17:27 +0100)
wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js

index 555fbebb14c77c7986cfff0f19a4463bfdea24dc..3d4754e83d9b5dcb23ec9d718aa99df9649de449 100644 (file)
@@ -189,9 +189,19 @@ define([], function() {
                 * @param       {Object<string, mixed>} styles  list of CSS styles
                 */
                setStyles: function(el, styles) {
+                       var important = false;
                        for (var property in styles) {
                                if (styles.hasOwnProperty(property)) {
-                                       el.style.setProperty(property, styles[property]);
+                                       if (/ !important$/.test(styles[property])) {
+                                               important = true;
+                                               
+                                               styles[property] = styles[property].replace(/ !important$/, '');
+                                       }
+                                       else {
+                                               important = false;
+                                       }
+                                       
+                                       el.style.setProperty(property, styles[property], (important ? 'important' : ''));
                                }
                        }
                },