jss-plugin-rule-value-function
Advanced tools
Comparing version 10.8.0 to 10.8.1
@@ -508,2 +508,12 @@ function warning(condition, message) { | ||
/** | ||
* 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. | ||
@@ -922,10 +932,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. | ||
@@ -1010,3 +1041,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options); | ||
this.updateOne(this.get(name), data, options); | ||
} else { | ||
@@ -1184,2 +1215,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 | ||
@@ -1211,8 +1276,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); | ||
} | ||
@@ -2022,4 +2087,2 @@ /** | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -2054,3 +2117,3 @@ ; | ||
this.id = instanceCounter++; | ||
this.version = "10.8.0"; | ||
this.version = "10.8.1"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -2057,0 +2120,0 @@ this.options = { |
{ | ||
"name": "jss-plugin-rule-value-function", | ||
"description": "JSS plugin for function value and rule syntax", | ||
"version": "10.8.0", | ||
"version": "10.8.1", | ||
"license": "MIT", | ||
@@ -46,6 +46,6 @@ "homepage": "https://cssinjs.org/", | ||
"@babel/runtime": "^7.3.1", | ||
"jss": "10.8.0", | ||
"jss": "10.8.1", | ||
"tiny-warning": "^1.0.2" | ||
}, | ||
"gitHead": "d2e1aea99b2a8a9c2d8725df1dfcd222d2504a7a" | ||
"gitHead": "3ff801f5e79c08a4b5d71288db4bd7d2f8a6c0f9" | ||
} |
@@ -11,3 +11,3 @@ # jss-plugin-rule-value-function | ||
See our website [jss-plugin-rule-value-function](https://cssinjs.org/jss-plugin-rule-value-function?v=v10.8.0) for more information. | ||
See our website [jss-plugin-rule-value-function](https://cssinjs.org/jss-plugin-rule-value-function?v=v10.8.1) for more information. | ||
@@ -14,0 +14,0 @@ ## Install |
79469
2148
+ Addedjss@10.8.1(transitive)
- Removedjss@10.8.0(transitive)
Updatedjss@10.8.1