* 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)
| 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. |
no test coverage detected