You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/writing-a-plugin.md
+33-31Lines changed: 33 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,37 +191,6 @@ if (decl.value.includes('gradient(')) {
191
191
}
192
192
```
193
193
194
-
Also you can use `Symbol()` to store some meta information, to make plugin faster, more efficient and well tested. For example, mark rule as `skipped`, to prevent unnecessary tasks and add counter for test `skipped` is working correctly:
Full [plugin](https://github.com/yunusga/postcss-momentum-scrolling/blob/master/index.js) and [test](https://github.com/yunusga/postcss-momentum-scrolling/blob/master/index.test.js#L15) example with `Symbol()` usage.
224
-
225
194
There two types or listeners: enter and exit. `Once`, `Root`, `AtRule`,
226
195
and `Rule` will be called before processing children. `OnceExit`, `RootExit`,
227
196
`AtRuleExit`, and `RuleExit` after processing all children inside node.
@@ -305,6 +274,39 @@ await postcss([plugin]).process('a { color: black }', { from })
305
274
// => color: red
306
275
```
307
276
277
+
Since visitors will re-visit node on any changes, just adding children will
278
+
cause an infinite loop. To prevent it, you need to check
279
+
that you already processed this node:
280
+
281
+
```js
282
+
Declaration: {
283
+
'will-change':decl=> {
284
+
if (decl.parent.some(decl=>decl.prop==='transform')) {
0 commit comments