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
James Yang edited this page Jan 10, 2017
·
2 revisions
Plugin Guide
How to write a plugin for cssobj? see below
Plugin Format
A plugin is an js object passed into plugins array of config (2nd) argument with cssobj call:
cssobj(obj,{plugins: [plugin1,plugin2, ...]})
All plugins just plain Javascript Objects, use type: function as key/value pair, like below:
cssobj(obj,{plugins: [{selector: (selector)=>{returnanother_selector}},// plugin1: changed to another_selector{value: (value,prop)=>{returnanother_value}},// plugin2: changed to another_value
...
]})
Plugin Type
Currently cssobj support below types
selector: function (selector: string, node: Node, result: Result) -> string
selector is current selector name according to CSS,
including normal @-rules, but except for group @-rules
@media, @document, @supports, @page, @keyframes
It's not recommanded to change above gorup @-rules, if you want doing so, use node.groupText
For node and result Object members, please see: Type Definition
Example plugin: add a container class to all selectors: