MCPcopy
hub / github.com/cssinjs/jss / replace

Method replace

packages/jss/src/RuleList.js:93–102  ·  view source on GitHub ↗

* Replace rule. * Create a new rule and remove old one instead of overwriting * because we want to invoke onCreateRule hook to make plugins work.

(name, decl, ruleOptions)

Source from the content-addressed store, hash-verified

91 * because we want to invoke onCreateRule hook to make plugins work.
92 */
93 replace(name, decl, ruleOptions) {
94 const oldRule = this.get(name)
95 const oldIndex = this.index.indexOf(oldRule)
96 if (oldRule) {
97 this.remove(oldRule)
98 }
99 let options = ruleOptions
100 if (oldIndex !== -1) options = {...ruleOptions, index: oldIndex}
101 return this.add(name, decl, options)
102 }
103
104 /**
105 * Get a rule by name or selector.

Callers 15

replaceRuleMethod · 0.80
addCamelCasedVersionFunction · 0.80
replaceRuleMethod · 0.80
escape.jsFile · 0.80
replaceRuleMethod · 0.80
findReferencedKeyframeFunction · 0.80
replaceParentRefsFunction · 0.80
onProcessStyleFunction · 0.80
getSheetOptionsFunction · 0.80
removeWhitespaceFunction · 0.80
removeVendorPrefixesFunction · 0.80
app.jsFile · 0.80

Calls 4

getMethod · 0.95
removeMethod · 0.95
addMethod · 0.95
indexOfMethod · 0.65

Tested by

no test coverage detected