@@ -416,14 +416,27 @@ var gZenUIManager = {
416416
417417 // Section: Notification messages
418418 _createToastElement ( messageId , options ) {
419+ const createButton = ( ) => {
420+ const button = document . createXULElement ( 'button' ) ;
421+ button . id = options . button . id ;
422+ button . classList . add ( 'footer-button' ) ;
423+ button . classList . add ( 'primary' ) ;
424+ button . addEventListener ( 'command' , options . button . command ) ;
425+ return button ;
426+ } ;
427+
419428 // Check if this message ID already exists
420429 for ( const child of this . _toastContainer . children ) {
421430 if ( child . _messageId === messageId ) {
422- if ( options . button && child . querySelector ( 'button' ) ) {
423- const button = child . querySelector ( 'button' ) ;
424- const clone = button . cloneNode ( true ) ;
425- button . replaceWith ( clone ) ;
426- clone . addEventListener ( 'command' , options . button . command ) ;
431+ child . removeAttribute ( 'button' ) ;
432+ if ( options . button ) {
433+ const button = createButton ( ) ;
434+ const existingButton = child . querySelector ( 'button' ) ;
435+ if ( existingButton ) {
436+ existingButton . remove ( ) ;
437+ }
438+ child . appendChild ( button ) ;
439+ child . setAttribute ( 'button' , true ) ;
427440 }
428441 return [ child , true ] ;
429442 }
@@ -441,11 +454,7 @@ var gZenUIManager = {
441454 }
442455 wrapper . appendChild ( element ) ;
443456 if ( options . button ) {
444- const button = document . createXULElement ( 'button' ) ;
445- button . id = options . button . id ;
446- button . classList . add ( 'footer-button' ) ;
447- button . classList . add ( 'primary' ) ;
448- button . addEventListener ( 'command' , options . button . command ) ;
457+ const button = createButton ( ) ;
449458 wrapper . appendChild ( button ) ;
450459 wrapper . setAttribute ( 'button' , true ) ;
451460 }
0 commit comments