File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -74,13 +74,21 @@ var mediaQueryHelper = (function (cssMediaQuery) {
74
74
'}' ;
75
75
} ;
76
76
77
+ var exchangeRuleWithNewContent = function ( styleSheet , ruleIdx , newRuleText ) {
78
+ try {
79
+ styleSheet . insertRule ( newRuleText , ruleIdx + 1 ) ;
80
+ } catch ( e ) {
81
+ // In case the browser does not like our new rule we just keep the existing one and quietly leave
82
+ return ;
83
+ }
84
+ styleSheet . deleteRule ( ruleIdx ) ;
85
+ } ;
86
+
77
87
var changeCssRule = function ( rule , newRuleText ) {
78
88
var styleSheet = rule . parentStyleSheet ,
79
89
ruleIdx = asArray ( styleSheet . cssRules ) . indexOf ( rule ) ;
80
90
81
- // Exchange rule with the new text
82
- styleSheet . insertRule ( newRuleText , ruleIdx + 1 ) ;
83
- styleSheet . deleteRule ( ruleIdx ) ;
91
+ exchangeRuleWithNewContent ( styleSheet , ruleIdx , newRuleText ) ;
84
92
} ;
85
93
86
94
var rewriteStyleContent = function ( styleElement ) {
You can’t perform that action at this time.
0 commit comments