app/assets/lookbook/js/lib/lookbook.js in lookbook-2.0.0.beta.2 vs app/assets/lookbook/js/lib/lookbook.js in lookbook-2.0.0.beta.3
- old
+ new
@@ -8,18 +8,28 @@
"panels",
"actions",
"param-*",
];
-function initEmbeds() {
+function initEmbeds(root = document) {
if (typeof window.iFrameResize !== "function") {
console.error(
"Lookbook embeds require the 'iframe-resizer' library to be available. Skipping embed instantiation."
);
return;
}
- const embeds = Array.from(document.querySelectorAll("lookbook-embed"));
+ if (typeof root === "string") {
+ root = document.querySelector(root);
+ }
+
+ if (!root) {
+ return console.error(
+ "Could not initialize Lookbook embeds. Root node not found."
+ );
+ }
+
+ const embeds = Array.from(root.querySelectorAll("lookbook-embed"));
embeds.forEach((embed) => {
const attrs = Array.from(embed.attributes);
const wrapper = createWrapper();
const iframe = createIframe(attrs);