@@ -23,13 +23,11 @@ interface ParseSVGStyleCallbackItemCommon {
2323 prop : string ;
2424 value : string ;
2525}
26- interface ParseSVGStyleCallbackItemInline
27- extends ParseSVGStyleCallbackItemCommon {
26+ interface ParseSVGStyleCallbackItemInline extends ParseSVGStyleCallbackItemCommon {
2827 type : 'inline' ;
2928 item : ParseSVGCallbackItem ;
3029}
31- interface ParseSVGStyleCallbackItemGlobal
32- extends ParseSVGStyleCallbackItemCommon {
30+ interface ParseSVGStyleCallbackItemGlobal extends ParseSVGStyleCallbackItemCommon {
3331 type : 'global' ;
3432 token : CSSRuleToken ;
3533 selectors : string [ ] ;
@@ -38,19 +36,16 @@ interface ParseSVGStyleCallbackItemGlobal
3836 nextTokens : CSSToken [ ] ;
3937}
4038
41- interface ParseSVGStyleCallbackItemGlobalAtRule
42- extends ParseSVGStyleCallbackItemCommon {
39+ interface ParseSVGStyleCallbackItemGlobalAtRule extends ParseSVGStyleCallbackItemCommon {
4340 token : CSSAtRuleToken ;
4441 childTokens : CSSToken [ ] ;
4542 prevTokens : ( CSSToken | null ) [ ] ;
4643 nextTokens : CSSToken [ ] ;
4744}
48- interface ParseSVGStyleCallbackItemGlobalGenericAtRule
49- extends ParseSVGStyleCallbackItemGlobalAtRule {
45+ interface ParseSVGStyleCallbackItemGlobalGenericAtRule extends ParseSVGStyleCallbackItemGlobalAtRule {
5046 type : 'at-rule' ;
5147}
52- interface ParseSVGStyleCallbackItemGlobalKeyframesAtRule
53- extends ParseSVGStyleCallbackItemGlobalAtRule {
48+ interface ParseSVGStyleCallbackItemGlobalKeyframesAtRule extends ParseSVGStyleCallbackItemGlobalAtRule {
5449 type : 'keyframes' ;
5550 from : Record < string , string > ;
5651}
@@ -96,12 +91,16 @@ export function parseSVGStyle(svg: SVG, callback: ParseSVGStyleCallback): void {
9691
9792 // Parse <style> tag
9893 function parseStyleItem ( ) {
99- const content = stringifyXMLContent ( node . children ) ;
94+ let content = stringifyXMLContent ( node . children ) ;
10095 if ( ! content ) {
10196 item . removeNode = true ;
10297 return ;
10398 }
10499
100+ // Remove '<![CDATA['
101+ content = content . replace ( '<![CDATA[' , '' ) . replace ( ']]>' , '' ) ;
102+
103+ // Parse style
105104 const tokens = getTokens ( content ) ;
106105 if ( ! ( tokens instanceof Array ) ) {
107106 // Invalid style
0 commit comments