jss-plugin-rule-value-observable
Advanced tools
Comparing version 10.8.2 to 10.9.0
@@ -544,2 +544,12 @@ function symbolObservablePonyfill(root) { | ||
/** | ||
* Replace rule, run plugins. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(name, style, options) { | ||
var newRule = this.rules.replace(name, style, options); | ||
if (newRule) this.options.jss.plugins.onProcessRule(newRule); | ||
return newRule; | ||
} | ||
/** | ||
* Generates a CSS string. | ||
@@ -958,10 +968,31 @@ */ | ||
/** | ||
* Get a rule. | ||
* Replace rule. | ||
* Create a new rule and remove old one instead of overwriting | ||
* because we want to invoke onCreateRule hook to make plugins work. | ||
*/ | ||
; | ||
_proto.get = function get(name) { | ||
return this.map[name]; | ||
_proto.replace = function replace(name, decl, ruleOptions) { | ||
var oldRule = this.get(name); | ||
var oldIndex = this.index.indexOf(oldRule); | ||
if (oldRule) { | ||
this.remove(oldRule); | ||
} | ||
var options = ruleOptions; | ||
if (oldIndex !== -1) options = _extends({}, ruleOptions, { | ||
index: oldIndex | ||
}); | ||
return this.add(name, decl, options); | ||
} | ||
/** | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.get = function get(nameOrSelector) { | ||
return this.map[nameOrSelector]; | ||
} | ||
/** | ||
* Delete a rule. | ||
@@ -1046,3 +1077,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options); | ||
this.updateOne(this.get(name), data, options); | ||
} else { | ||
@@ -1220,2 +1251,36 @@ for (var index = 0; index < this.index.length; index++) { | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(nameOrSelector, decl, options) { | ||
var oldRule = this.rules.get(nameOrSelector); | ||
if (!oldRule) return this.addRule(nameOrSelector, decl, options); | ||
var newRule = this.rules.replace(nameOrSelector, decl, options); | ||
if (newRule) { | ||
this.options.jss.plugins.onProcessRule(newRule); | ||
} | ||
if (this.attached) { | ||
if (!this.deployed) return newRule; // Don't replace / delete rule directly if there is no stringified version yet. | ||
// It will be inserted all together when .attach is called. | ||
if (this.renderer) { | ||
if (!newRule) { | ||
this.renderer.deleteRule(oldRule); | ||
} else if (oldRule.renderable) { | ||
this.renderer.replaceRule(oldRule.renderable, newRule); | ||
} | ||
} | ||
return newRule; | ||
} // We can't replace rules to a detached style node. | ||
// We will redeploy the sheet once user will attach it. | ||
this.deployed = false; | ||
return newRule; | ||
} | ||
/** | ||
* Insert rule into the StyleSheet | ||
@@ -1247,8 +1312,8 @@ */ | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.getRule = function getRule(name) { | ||
return this.rules.get(name); | ||
_proto.getRule = function getRule(nameOrSelector) { | ||
return this.rules.get(nameOrSelector); | ||
} | ||
@@ -2032,3 +2097,3 @@ /** | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule; | ||
this.cssRules.splice(index, 0, cssRule); | ||
} | ||
@@ -2059,4 +2124,2 @@ } | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -2091,3 +2154,3 @@ ; | ||
this.id = instanceCounter++; | ||
this.version = "10.8.2"; | ||
this.version = "10.9.0"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -2094,0 +2157,0 @@ this.options = { |
{ | ||
"name": "jss-plugin-rule-value-observable", | ||
"description": "JSS plugin for TC39 Observables support", | ||
"version": "10.8.2", | ||
"version": "10.9.0", | ||
"license": "MIT", | ||
@@ -45,6 +45,6 @@ "homepage": "https://cssinjs.org/", | ||
"@babel/runtime": "^7.3.1", | ||
"jss": "10.8.2", | ||
"jss": "10.9.0", | ||
"symbol-observable": "^1.2.0" | ||
}, | ||
"gitHead": "e693eca21f1557ea350fba0a7a3db0949cb7cac5" | ||
"gitHead": "359b55916cbc15653a3ca052841296bcd325bc86" | ||
} |
@@ -11,3 +11,3 @@ # jss-plugin-rule-value-observable | ||
See our website [jss-plugin-rule-value-observable](https://cssinjs.org/jss-plugin-rule-value-observable?v=v10.8.2) for more information. | ||
See our website [jss-plugin-rule-value-observable](https://cssinjs.org/jss-plugin-rule-value-observable?v=v10.9.0) for more information. | ||
@@ -14,0 +14,0 @@ ## Install |
77252
2117
+ Addedjss@10.9.0(transitive)
- Removedjss@10.8.2(transitive)
Updatedjss@10.9.0