From 41b4963af5b89d46957e846e0a8d57a4f03f1c85 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Fri, 30 Aug 2019 21:23:34 +0000 Subject: [PATCH] Bug 1573158 - Share one fragment across all consumers of places-popup r=surkov This will avoid parsing the markup strings into fragments for every consumer. Differential Revision: https://phabricator.services.mozilla.com/D43846 --HG-- extra : moz-landing-system : lando --- .../components/places/content/places-menupopup.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/browser/components/places/content/places-menupopup.js b/browser/components/places/content/places-menupopup.js index eb7b127ed0cb..7490472fba0e 100644 --- a/browser/components/places/content/places-menupopup.js +++ b/browser/components/places/content/places-menupopup.js @@ -34,6 +34,15 @@ this.attachShadow({ mode: "open" }); } + get fragment() { + if (!this.constructor.hasOwnProperty("_fragment")) { + this.constructor._fragment = MozXULElement.parseXULToFragment( + this.markup + ); + } + return document.importNode(this.constructor._fragment, true); + } + get markup() { return ` @@ -55,9 +64,7 @@ } this.shadowRoot.textContent = ""; - this.shadowRoot.appendChild( - MozXULElement.parseXULToFragment(this.markup) - ); + this.shadowRoot.appendChild(this.fragment); this._indicatorBar = this.shadowRoot.querySelector( "[part=drop-indicator-bar]"