There are a few benefits of custom implementation
- csstree instead of css-what parser
- 9 less dependecies
- only standard features are supported (css-select has :parent from jquery)
- new implementation allows to get rid of parentNode
Wrapping each node with JSAPI class and passing parent to it is not
reliable. Parent may be changed but the reference will stay.
Here I wasn't able to detach comment from parent node for some reason.
Explicit parent node inferred while ast traverse is easier to debug and
work with. Eventually we will not need to wrap each node with JSAPI class.
Visitor is a simple pattern which helps to avoid many type checks
and provide both "perItem" and "perItemReverse" functionality without
fragmentation.
The most important case is an ability to define state which in many
plugins specified either on module level or by polluting `params`.
In this diff I added visit and detachFromParent utilities and refactored
new mergeStyles plugin with it.
Also fixed bug when cdata content is merged into "text" node which is
not always valid.