Fix style property issue in Safari
authorMatthias Schmidt <gravatronics@live.com>
Thu, 17 Mar 2016 18:14:27 +0000 (19:14 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 17 Mar 2016 18:14:27 +0000 (19:14 +0100)
wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js

index a230a6c289d4afd501afa4e30069fdb5a967fb3b..5d29a684dc9740280c94cb22c2970fc92a58afca 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Dom/Util
  */
-define(['StringUtil'], function(StringUtil) {
+define(['Environment', 'StringUtil'], function(Environment, StringUtil) {
        "use strict";
        
        function _isBoundaryNode(element, ancestor, position) {
@@ -208,6 +208,13 @@ define(['StringUtil'], function(StringUtil) {
                                                important = false;
                                        }
                                        
+                                       // for a set style property with priority = important, Safari is not able to
+                                       // overwrite it with a property != important; removing the property first
+                                       // solves the issue
+                                       if (Environment.browser() === 'safari' && el.style.getPropertyPriority(property) === 'important' && !important) {
+                                               el.style.removeProperty(property);
+                                       }
+                                       
                                        el.style.setProperty(property, styles[property], (important ? 'important' : ''));
                                }
                        }