diff --git a/browser/components/pocket/content/panels/js/saved.js b/browser/components/pocket/content/panels/js/saved.js index 4f5f3bf941d1..f08092823e05 100644 --- a/browser/components/pocket/content/panels/js/saved.js +++ b/browser/components/pocket/content/panels/js/saved.js @@ -703,10 +703,10 @@ PKT_PANEL_OVERLAY.prototype = { document .querySelector(`body`) .append( - parser.parseFromString( + ...parser.parseFromString( Handlebars.templates.saved_shell(templateData), `text/html` - ).documentElement + ).body.childNodes ); // Add in premium content (if applicable based on premium status) @@ -716,12 +716,17 @@ PKT_PANEL_OVERLAY.prototype = { ) { let elSubshell = document.querySelector(`body .pkt_ext_subshell`); - let elPremiumShell = parser.parseFromString( + let elPremiumShellElements = parser.parseFromString( Handlebars.templates.saved_premiumshell(templateData), `text/html` - ).documentElement; + ).body.childNodes; - elSubshell.insertBefore(elPremiumShell, elSubshell.firstChild); + // Convert NodeList to Array and reverse it + elPremiumShellElements = [].slice.call(elPremiumShellElements).reverse(); + + elPremiumShellElements.forEach(el => { + elSubshell.insertBefore(el, elSubshell.firstChild); + }); } // Initialize functionality for overlay