Bug 1503047 - Fix snippets not loading by ensuring snippets element exists. r=andreio, a=pascalc
authork88hudson <k88hudson@gmail.com>
Tue, 30 Oct 2018 02:43:17 +0000
changeset 492958 57ecd86334a5be4ada8f24d8bdb82880f5172264
parent 492957 f44ea719baf6fd48ac8ce66b2248795dfcfb2627
child 492959 6d5e52718c0092c7cc8c5d07b01803debc1cb2f2
push id1837
push userryanvm@gmail.com
push dateTue, 30 Oct 2018 13:56:59 +0000
treeherdermozilla-release@57ecd86334a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersandreio, pascalc
bugs1503047
milestone63.0.1
Bug 1503047 - Fix snippets not loading by ensuring snippets element exists. r=andreio, a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D10157
browser/components/newtab/data/content/activity-stream.bundle.js
--- a/browser/components/newtab/data/content/activity-stream.bundle.js
+++ b/browser/components/newtab/data/content/activity-stream.bundle.js
@@ -757,21 +757,23 @@ class SnippetsProvider {
     const onboardingEl = document.getElementById("onboarding-notification-bar");
 
     if (onboardingEl) {
       onboardingEl.style.display = shouldBeVisible ? "" : "none";
     }
   }
 
   _showRemoteSnippets() {
-    const snippetsEl = document.getElementById(this.elementId);
+    let snippetsEl = document.getElementById(this.elementId);
     const payload = this.snippetsMap.get("snippets");
 
     if (!snippetsEl) {
-      throw new Error(`No element was found with id '${this.elementId}'.`);
+      snippetsEl = document.createElement("div");
+      snippetsEl.id = "snippets";
+      document.getElementById("snippets-container").appendChild(snippetsEl);
     }
 
     // This could happen if fetching failed
     if (!payload) {
       throw new Error("No remote snippets were found in gSnippetsMap.");
     }
 
     if (typeof payload !== "string") {
@@ -1214,17 +1216,18 @@ ASRouterUISurface.defaultProps = { docum
 
 class ASRouterContent {
   constructor() {
     this.initialized = false;
     this.containerElement = null;
   }
 
   _mount() {
-    this.containerElement = global.document.getElementById("snippets-container");
+    this.containerElement = document.createElement("asr-container");
+    global.document.body.appendChild(this.containerElement);
     react_dom__WEBPACK_IMPORTED_MODULE_7___default.a.render(react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(ASRouterUISurface, null), this.containerElement);
   }
 
   _unmount() {
     react_dom__WEBPACK_IMPORTED_MODULE_7___default.a.unmountComponentAtNode(this.containerElement);
   }
 
   init() {