-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gutenberg iframe editor error: [splide] A track/list element is missing. #47
Comments
Having this very same issue while trying to run the carousel on an iframe. @kadencewp you should send a PR for this, your update works like charm in here! |
I still don't understand what is the actual problem. |
@NaotoshiFujita exactly, it does not. The update proposed by @kadencewp fixes it. |
@marbiano How do I reproduce it? If I load my page in |
This issue is also sometimes present in Chrome when not using an iframe. We fixed it for now with the suggested code from @kadencewp by patching the package with This is our patch file (we're using react-splide): diff --git a/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js b/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js
index ddf5aa5..0f2f7d9 100644
--- a/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js
+++ b/node_modules/@splidejs/react-splide/dist/js/react-splide.cjs.js
@@ -93,7 +93,10 @@ function isNull(subject) {
return subject === null;
}
function isHTMLElement(subject) {
- return subject instanceof HTMLElement;
+ return (
+ typeof HTMLElement === "object" ? subject instanceof HTMLElement : //DOM2
+ subject && typeof subject === "object" && subject !== null && subject.nodeType === 1 && typeof subject.nodeName==="string"
+ );
}
function toArray(value) {
return isArray(value) ? value : [value];
diff --git a/node_modules/@splidejs/react-splide/dist/js/react-splide.esm.js b/node_modules/@splidejs/react-splide/dist/js/react-splide.esm.js
index daf9966..3bb87f4 100644
--- a/node_modules/@splidejs/react-splide/dist/js/react-splide.esm.js
+++ b/node_modules/@splidejs/react-splide/dist/js/react-splide.esm.js
@@ -63,7 +63,10 @@ function isNull(subject) {
return subject === null;
}
function isHTMLElement(subject) {
- return subject instanceof HTMLElement;
+ return (
+ typeof HTMLElement === "object" ? subject instanceof HTMLElement : //DOM2
+ subject && typeof subject === "object" && subject !== null && subject.nodeType === 1 && typeof subject.nodeName==="string"
+ );
}
function toArray(value) {
return isArray(value) ? value : [value]; |
Checks
Version
0.7.7
Description
Hi!
When trying to use in Gutenberg (WordPress Block Editor) everything is fine until you open in their iframe editor. Gutenberg currently uses an iframe editor for tablet and mobile previews as well as their site builder.
The error in the console log is:
Upon digging into the issue I was able to find that the function isHTMLElement returns false when it should return true.
Currently isHTMLElement function is:
If that is updated to:
Then things work in the iframe editor. That code came from this stackoverflow: https://stackoverflow.com/questions/384286/how-do-you-check-if-a-javascript-object-is-a-dom-object
Thoughts on this? Would it be helpful if I added a pull request with this change, or perhaps you have another solution?
Reproduction Link
No response
Steps to Reproduce
...
Expected Behaviour
When using splide in an iframe editor is should render correctly.
The text was updated successfully, but these errors were encountered: