Skip to content

Commit

Permalink
Fix issue #523 - "Slider cannot be initialized in iframe #523"
Browse files Browse the repository at this point in the history
  • Loading branch information
jayelkaake committed Nov 9, 2023
1 parent 87b3be2 commit f6b63df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f6b63df

Please sign in to comment.