@@ -492,12 +492,13 @@ function find_comment(nodes, text, start) {
492492 return nodes . length ;
493493}
494494
495- export function claim_html_tag ( nodes ) {
495+
496+ export function claim_html_tag ( nodes , is_svg : boolean ) {
496497 // find html opening tag
497498 const start_index = find_comment ( nodes , 'HTML_TAG_START' , 0 ) ;
498499 const end_index = find_comment ( nodes , 'HTML_TAG_END' , start_index ) ;
499500 if ( start_index === end_index ) {
500- return new HtmlTagHydration ( ) ;
501+ return new HtmlTagHydration ( undefined , is_svg ) ;
501502 }
502503
503504 init_claim_info ( nodes ) ;
@@ -509,7 +510,7 @@ export function claim_html_tag(nodes) {
509510 n . claim_order = nodes . claim_info . total_claimed ;
510511 nodes . claim_info . total_claimed += 1 ;
511512 }
512- return new HtmlTagHydration ( claimed_nodes ) ;
513+ return new HtmlTagHydration ( claimed_nodes , is_svg ) ;
513514}
514515
515516export function set_data ( text , data ) {
@@ -645,26 +646,33 @@ export function query_selector_all(selector: string, parent: HTMLElement = docum
645646}
646647
647648export class HtmlTag {
649+ private is_svg = false ;
648650 // parent for creating node
649- e : HTMLElement ;
651+ e : HTMLElement | SVGElement ;
650652 // html tag nodes
651653 n : ChildNode [ ] ;
652654 // target
653- t : HTMLElement ;
655+ t : HTMLElement | SVGElement ;
654656 // anchor
655- a : HTMLElement ;
657+ a : HTMLElement | SVGElement ;
656658
657- constructor ( ) {
659+ constructor ( is_svg : boolean = false ) {
660+ this . is_svg = is_svg ;
658661 this . e = this . n = null ;
659662 }
660663
661664 c ( html : string ) {
662665 this . h ( html ) ;
663666 }
664667
665- m ( html : string , target : HTMLElement , anchor : HTMLElement = null ) {
668+ m (
669+ html : string ,
670+ target : HTMLElement | SVGElement ,
671+ anchor : HTMLElement | SVGElement = null
672+ ) {
666673 if ( ! this . e ) {
667- this . e = element ( target . nodeName as keyof HTMLElementTagNameMap ) ;
674+ if ( this . is_svg ) this . e = svg_element ( target . nodeName as keyof SVGElementTagNameMap ) ;
675+ else this . e = element ( target . nodeName as keyof HTMLElementTagNameMap ) ;
668676 this . t = target ;
669677 this . c ( html ) ;
670678 }
@@ -698,8 +706,8 @@ export class HtmlTagHydration extends HtmlTag {
698706 // hydration claimed nodes
699707 l : ChildNode [ ] | void ;
700708
701- constructor ( claimed_nodes ?: ChildNode [ ] ) {
702- super ( ) ;
709+ constructor ( claimed_nodes ?: ChildNode [ ] , is_svg : boolean = false ) {
710+ super ( is_svg ) ;
703711 this . e = this . n = null ;
704712 this . l = claimed_nodes ;
705713 }
0 commit comments