@@ -305,27 +305,32 @@ export class Cal {
305305 // },
306306 // },
307307 // });
308- let attributesString = "" ;
309- let existingEl = null ;
308+ let existingEl : HTMLElement | null = null ;
309+
310310 if ( attributes ?. id ) {
311- attributesString += ` id="${ attributes . id } "` ;
312311 existingEl = document . getElementById ( attributes . id ) ;
313312 }
314- let el = existingEl ;
313+ let el : HTMLElement ;
315314 if ( ! existingEl ) {
316- const template = document . createElement ( "template" ) ;
317- template . innerHTML = `<cal-floating-button ${ attributesString } data-cal-namespace="${ this . namespace } " data-cal-link="${ calLink } "></cal-floating-button>` ;
318- el = template . content . children [ 0 ] as HTMLElement ;
319- document . body . appendChild ( template . content ) ;
315+ el = document . createElement ( "cal-floating-button" ) ;
316+ el . dataset . calLink = calLink ;
317+ el . dataset . calNamespace = this . namespace ;
318+ if ( attributes ?. id ) {
319+ el . id = attributes . id ;
320+ }
321+
322+ document . body . appendChild ( el ) ;
323+ } else {
324+ el = existingEl ;
320325 }
321326
322327 if ( buttonText ) {
323- el ! . setAttribute ( "data-button-text" , buttonText ) ;
328+ el . setAttribute ( "data-button-text" , buttonText ) ;
324329 }
325- el ! . setAttribute ( "data-hide-button-icon" , "" + hideButtonIcon ) ;
326- el ! . setAttribute ( "data-button-position" , "" + buttonPosition ) ;
327- el ! . setAttribute ( "data-button-color" , "" + buttonColor ) ;
328- el ! . setAttribute ( "data-button-text-color" , "" + buttonTextColor ) ;
330+ el . setAttribute ( "data-hide-button-icon" , "" + hideButtonIcon ) ;
331+ el . setAttribute ( "data-button-position" , "" + buttonPosition ) ;
332+ el . setAttribute ( "data-button-color" , "" + buttonColor ) ;
333+ el . setAttribute ( "data-button-text-color" , "" + buttonTextColor ) ;
329334 }
330335
331336 modal ( { calLink, config = { } , uid } : { calLink : string ; config ?: Record < string , string > ; uid : number } ) {
0 commit comments