From f6b63df48a3f323cd1478c51760f332a86edff21 Mon Sep 17 00:00:00 2001 From: Jay El-Kaake Date: Thu, 9 Nov 2023 18:09:34 -0500 Subject: [PATCH] Fix issue https://github.com/glidejs/glide/issues/523 - "Slider cannot be initialized in iframe #523" --- src/components/html.js | 2 +- src/utils/dom.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/html.js b/src/components/html.js index 6e8a7127..d2ef86d5 100644 --- a/src/components/html.js +++ b/src/components/html.js @@ -48,7 +48,7 @@ export default function (Glide, Components, Events) { r = document.querySelector(r) } - if (r !== null) { + if (exist(r)) { Html._r = r } else { warn('Root element must be a existing Html node') diff --git a/src/utils/dom.js b/src/utils/dom.js index 91289ccf..a0001516 100644 --- a/src/utils/dom.js +++ b/src/utils/dom.js @@ -28,7 +28,8 @@ export function siblings (node) { * @return {Boolean} */ export function exist (node) { - if (node && node instanceof window.HTMLElement) { + // We are usine duck-typing here because we can't use `instanceof` since if we're in an iframe the class instance will be different. + if (node && node.appendChild && node.isConnected) { return true }