@@ -20,6 +20,7 @@ import { string_to_member_expression } from '../../../utils/string_to_member_exp
2020import SlotTemplate from '../../../nodes/SlotTemplate' ;
2121import { is_head } from '../shared/is_head' ;
2222import compiler_warnings from '../../../compiler_warnings' ;
23+ import { namespaces } from '../../../../utils/namespaces' ;
2324
2425type SlotDefinition = { block : Block ; scope : TemplateScope ; get_context ?: Node ; get_changes ?: Node } ;
2526
@@ -150,7 +151,9 @@ export default class InlineComponentWrapper extends Wrapper {
150151 }
151152
152153 const has_css_custom_properties = this . node . css_custom_properties . length > 0 ;
153- const css_custom_properties_wrapper = has_css_custom_properties ? block . get_unique_name ( 'div' ) : null ;
154+ const is_svg_namespace = this . node . namespace === namespaces . svg ;
155+ const css_custom_properties_wrapper_element = is_svg_namespace ? 'g' : 'div' ;
156+ const css_custom_properties_wrapper = has_css_custom_properties ? block . get_unique_name ( css_custom_properties_wrapper_element ) : null ;
154157 if ( has_css_custom_properties ) {
155158 block . add_variable ( css_custom_properties_wrapper ) ;
156159 }
@@ -411,7 +414,7 @@ export default class InlineComponentWrapper extends Wrapper {
411414 const snippet = this . node . expression . manipulate ( block ) ;
412415
413416 if ( has_css_custom_properties ) {
414- this . set_css_custom_properties ( block , css_custom_properties_wrapper ) ;
417+ this . set_css_custom_properties ( block , css_custom_properties_wrapper , css_custom_properties_wrapper_element , is_svg_namespace ) ;
415418 }
416419
417420 block . chunks . init . push ( b `
@@ -440,7 +443,7 @@ export default class InlineComponentWrapper extends Wrapper {
440443 block . chunks . mount . push ( b `if (${ name } ) @mount_component(${ name } , ${ mount_target } , ${ mount_anchor } );` ) ;
441444
442445 if ( to_claim ) {
443- if ( css_custom_properties_wrapper ) claim_nodes = this . create_css_custom_properties_wrapper_claim_chunk ( block , claim_nodes , css_custom_properties_wrapper ) ;
446+ if ( css_custom_properties_wrapper ) claim_nodes = this . create_css_custom_properties_wrapper_claim_chunk ( block , claim_nodes , css_custom_properties_wrapper , css_custom_properties_wrapper_element , is_svg_namespace ) ;
444447 block . chunks . claim . push ( b `if (${ name } ) @claim_component(${ name } .$$.fragment, ${ claim_nodes } );` ) ;
445448 }
446449
@@ -514,15 +517,15 @@ export default class InlineComponentWrapper extends Wrapper {
514517 ` ) ;
515518
516519 if ( has_css_custom_properties ) {
517- this . set_css_custom_properties ( block , css_custom_properties_wrapper ) ;
520+ this . set_css_custom_properties ( block , css_custom_properties_wrapper , css_custom_properties_wrapper_element , is_svg_namespace ) ;
518521 }
519522 block . chunks . create . push ( b `@create_component(${ name } .$$.fragment);` ) ;
520523
521524 if ( css_custom_properties_wrapper ) this . create_css_custom_properties_wrapper_mount_chunk ( block , parent_node , css_custom_properties_wrapper ) ;
522525 block . chunks . mount . push ( b `@mount_component(${ name } , ${ mount_target } , ${ mount_anchor } );` ) ;
523526
524527 if ( to_claim ) {
525- if ( css_custom_properties_wrapper ) claim_nodes = this . create_css_custom_properties_wrapper_claim_chunk ( block , claim_nodes , css_custom_properties_wrapper ) ;
528+ if ( css_custom_properties_wrapper ) claim_nodes = this . create_css_custom_properties_wrapper_claim_chunk ( block , claim_nodes , css_custom_properties_wrapper , css_custom_properties_wrapper_element , is_svg_namespace ) ;
526529 block . chunks . claim . push ( b `@claim_component(${ name } .$$.fragment, ${ claim_nodes } );` ) ;
527530 }
528531
@@ -568,22 +571,28 @@ export default class InlineComponentWrapper extends Wrapper {
568571 private create_css_custom_properties_wrapper_claim_chunk (
569572 block : Block ,
570573 parent_nodes : Identifier ,
571- css_custom_properties_wrapper : Identifier | null
574+ css_custom_properties_wrapper : Identifier | null ,
575+ css_custom_properties_wrapper_element : string ,
576+ is_svg_namespace : boolean
572577 ) {
573578 const nodes = block . get_unique_name ( `${ css_custom_properties_wrapper . name } _nodes` ) ;
579+ const claim_element = is_svg_namespace ? x `@claim_svg_element` : x `@claim_element` ;
574580 block . chunks . claim . push ( b `
575- ${ css_custom_properties_wrapper } = @ claim_element(${ parent_nodes } , "DIV ", { style: true })
581+ ${ css_custom_properties_wrapper } = ${ claim_element } (${ parent_nodes } , "${ css_custom_properties_wrapper_element . toUpperCase ( ) } ", { style: true })
576582 var ${ nodes } = @children(${ css_custom_properties_wrapper } );
577583 ` ) ;
578584 return nodes ;
579585 }
580586
581587 private set_css_custom_properties (
582588 block : Block ,
583- css_custom_properties_wrapper : Identifier
589+ css_custom_properties_wrapper : Identifier ,
590+ css_custom_properties_wrapper_element : string ,
591+ is_svg_namespace : boolean
584592 ) {
585- block . chunks . create . push ( b `${ css_custom_properties_wrapper } = @element("div");` ) ;
586- block . chunks . hydrate . push ( b `@set_style(${ css_custom_properties_wrapper } , "display", "contents");` ) ;
593+ const element = is_svg_namespace ? x `@svg_element` : x `@element` ;
594+ block . chunks . create . push ( b `${ css_custom_properties_wrapper } = ${ element } ("${ css_custom_properties_wrapper_element } ");` ) ;
595+ if ( ! is_svg_namespace ) block . chunks . hydrate . push ( b `@set_style(${ css_custom_properties_wrapper } , "display", "contents");` ) ;
587596 this . node . css_custom_properties . forEach ( ( attr ) => {
588597 const dependencies = attr . get_dependencies ( ) ;
589598 const should_cache = attr . should_cache ( ) ;
0 commit comments