CSSTransformers.CSSTransformerBase()

CSS AST transformer. To apply this transformer call CSSTransformerBase.transform(el). Base class for CSS AST transformer. Advanced usage notes: You can subclass it to implement your own transformer. Just remember to call this.transformSubElements(el.children) if you deal with multi-level items (roots, rules, at rules).

new CSSTransformerBase()

Internal state initializer. To apply transformer use CSSTransformerBase.transform(el) instead.

Methods

static transform(el)

Transform AST using this transformer.

Parameters:
Name Type Description
el ASTNode | Array.<ASTNode>

Element.

atRule(el, i, parentChildren, cbnullable)

At rule transformer.

Parameters:
Name Type Attributes Description
el AtRule

Element.

i number

Element index.

parentChildren Array.<ASTNode>

Element's parent children list.

cb function <nullable>

Callback.

comment(el, i, parentChildren, cbnullable)

Comment transformer.

Parameters:
Name Type Attributes Description
el Comment

Element.

i number

Element index.

parentChildren Array.<ASTNode>

Element's parent children list.

cb function <nullable>

Callback.

declaration(el, i, parentChildren, cbnullable)

Declaration transformer.

Parameters:
Name Type Attributes Description
el Declaration

Element.

i number

Element index.

parentChildren Array.<ASTNode>

Element's parent children list.

cb function <nullable>

Callback.

getTransformer(el) → {function}

Get node transformer.

Parameters:
Name Type Description
el ASTNode

Element.

Returns:
function -

Node transformer.

root(el, inullable, parentChildrennullable, cbnullable)

Root node transformer.

Parameters:
Name Type Attributes Description
el Array.<Rule>

Root element.

i number <nullable>

Root element index if any.

parentChildren Array.<ASTNode> <nullable>

Children of root element parent if there is any parent.

cb function <nullable>

Callback.

rule(el, i, parentChildren, cbnullable)

Rule transformer.

Parameters:
Name Type Attributes Description
el Rule

Element.

i number

Element index.

parentChildren Array.<ASTNode>

Element's parent children list.

cb function <nullable>

Callback.

transformSubElements(elements, listnullable, whitelistnullable)

Transform all (or with exclusions) provided sub elements.

Parameters:
Name Type Attributes Description
elements Array.<ASTNode>

Array of elements.

list Array.<string> <nullable>

Blacklist or whitelist of types.

whitelist boolean <nullable>

Whether list is whitelist or blacklist.