1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-01 18:46:52 +03:00
Files
svgo/test/plugins/mergeStyles.11.svg
Bogdan Chadkin 27bef1a954 Add "visitor" plugins support (#1454)
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.
2021-03-28 11:20:17 +03:00

25 lines
485 B
XML

Convert content to cdata if any style element contains cdata
===
<svg id="test" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<style>
.st0 { fill: yellow; }
</style>
<style>
<![CDATA[
.st1 { fill: red; }
]]>
</style>
</svg>
@@@
<svg id="test" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<style>
<![CDATA[.st0 { fill: yellow; }
.st1 { fill: red; }
]]>
</style>
</svg>