Bug 1551312 - allow customized built-in buttons to be passed to notificationbox r=bgrins
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Wed, 15 May 2019 20:14:30 +0000
changeset 532877 d15e60f91051c45b51a5c8cf130eaa03ef24ce62
parent 532876 67e719e02573ca3325763b9c1778ccf33a1738e1
child 532878 2a832d03ebcc4199e682e7b1160eb47e9bd87e1d
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1551312
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551312 - allow customized built-in buttons to be passed to notificationbox r=bgrins Allow customized built-in buttons to be used for the notificationbox buttons. This way e.g. <button type=menu-button> can be used there. Differential Revision: https://phabricator.services.mozilla.com/D30971
toolkit/content/widgets/notificationbox.js
--- a/toolkit/content/widgets/notificationbox.js
+++ b/toolkit/content/widgets/notificationbox.js
@@ -94,16 +94,19 @@ MozElements.NotificationBox = class Noti
    *            When the button is used, this is called with the arguments:
    *             1. The <notification> element.
    *             2. This button object definition.
    *             3. The <button> element.
    *             4. The "command" event.
    *          popup:
    *            If specified, the button will open the popup element with this
    *            ID, anchored to the button. This is alternative to "callback".
+   *          is:
+   *            Defines a Custom Element name to use as the "is" value on
+   *            button creation.
    *        }
    * @param aEventCallback
    *        This may be called with the "removed" or "dismissed" parameter.
    * @param aNotificationIs
    *        Defines a Custom Element name to use as the "is" value on creation.
    *        This allows subclassing the created element.
    *
    * @return The <notification> element that is shown.
@@ -143,17 +146,18 @@ MozElements.NotificationBox = class Noti
     if (aImage) {
       newitem.messageImage.setAttribute("src", aImage);
     }
     newitem.eventCallback = aEventCallback;
 
     if (aButtons) {
       for (var b = 0; b < aButtons.length; b++) {
         var button = aButtons[b];
-        var buttonElem = document.createXULElement("button");
+        var buttonElem = document.createXULElement("button",
+          button.is ? { is: button.is } : {});
 
         if (button["l10n-id"]) {
             buttonElem.setAttribute("data-l10n-id", button["l10n-id"]);
         } else {
             buttonElem.setAttribute("label", button.label);
             if (typeof button.accessKey == "string")
                 buttonElem.setAttribute("accesskey", button.accessKey);
         }