Bug 1576601 - Add click listener only to the link in the protections panel info message. r=andreio a=lizzard
authorNihanth Subramanya <nhnt11@gmail.com>
Mon, 30 Sep 2019 11:39:34 +0000
changeset 555437 afca95b1be523be9181ca2484c59a948f6909d8c
parent 555436 a3c6b250563d4a01500c44fc6533c811ef564e48
child 555438 5e3a5cbccbb70bc2bc34665b44e697e5c330c053
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersandreio, lizzard
bugs1576601
milestone70.0
Bug 1576601 - Add click listener only to the link in the protections panel info message. r=andreio a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D47445
browser/components/newtab/lib/ToolbarPanelHub.jsm
--- a/browser/components/newtab/lib/ToolbarPanelHub.jsm
+++ b/browser/components/newtab/lib/ToolbarPanelHub.jsm
@@ -305,35 +305,35 @@ class _ToolbarPanelHub {
   _createHeroElement(win, doc, message) {
     const messageEl = this._createElement(doc, "div");
     messageEl.setAttribute("id", "protections-popup-message");
     messageEl.classList.add("whatsNew-hero-message");
     const wrapperEl = this._createElement(doc, "div");
     wrapperEl.classList.add("whatsNew-message-body");
     messageEl.appendChild(wrapperEl);
 
-    this._attachClickListener(win, wrapperEl, message);
-
     wrapperEl.appendChild(
       this._createElement(doc, "h2", {
         classList: "whatsNew-message-title",
         content: message.content.title,
       })
     );
     wrapperEl.appendChild(
       this._createElement(doc, "p", { content: message.content.body })
     );
 
     if (message.content.link_text) {
-      wrapperEl.appendChild(
-        this._createElement(doc, "a", {
-          classList: "text-link",
-          content: message.content.link_text,
-        })
-      );
+      let linkEl = this._createElement(doc, "a", {
+        classList: "text-link",
+        content: message.content.link_text,
+      });
+      wrapperEl.appendChild(linkEl);
+      this._attachClickListener(win, linkEl, message);
+    } else {
+      this._attachClickListener(win, wrapperEl, message);
     }
 
     return messageEl;
   }
 
   _createElement(doc, elem, options = {}) {
     const node = doc.createElementNS("http://www.w3.org/1999/xhtml", elem);
     if (options.classList) {