File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1050,19 +1050,22 @@ function AIWidget() {
10501050 */
10511051 this . _scale = function ( ) {
10521052 let width , height ;
1053- const canvas = document . getElementsByClassName ( "samplerCanvas" ) ;
10541053 const body = this . widgetWindow . getWidgetBody ( ) ;
1055- for ( let i = canvas . length - 1 ; i >= 0 ; i -- ) {
1056- body . removeChild ( canvas [ i ] ) ;
1054+
1055+ // Properly remove the entire previous interface container to avoid leaks
1056+ const containers = body . getElementsByClassName ( "ai-interface-container" ) ;
1057+ for ( let i = containers . length - 1 ; i >= 0 ; i -- ) {
1058+ body . removeChild ( containers [ i ] ) ;
10571059 }
1060+
10581061 if ( ! this . widgetWindow . isMaximized ( ) ) {
10591062 width = SAMPLEWIDTH ;
10601063 height = SAMPLEHEIGHT ;
10611064 } else {
10621065 width = this . widgetWindow . getWidgetBody ( ) . getBoundingClientRect ( ) . width ;
10631066 height = this . widgetWindow . getWidgetFrame ( ) . getBoundingClientRect ( ) . height - 70 ;
10641067 }
1065- document . getElementsByTagName ( "canvas" ) [ 0 ] . innerHTML = "" ;
1068+
10661069 this . makeCanvas ( width , height , 0 , true ) ;
10671070 this . reconnectSynthsToAnalyser ( ) ;
10681071 } ;
@@ -1081,6 +1084,7 @@ function AIWidget() {
10811084
10821085 // Create a container to center the elements
10831086 const container = document . createElement ( "div" ) ;
1087+ container . className = "ai-interface-container" ;
10841088 fragment . appendChild ( container ) ;
10851089
10861090 // Create a scrollable container for the textarea
You can’t perform that action at this time.
0 commit comments