-
Notifications
You must be signed in to change notification settings - Fork 645
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
Strange bug when looping through elements and adding to DOM (JavaScript bugs) #3525
Comments
Ok progress. By selecting 'Client only' this fixes. I think overall this needs to be clearer or maybe something automatic when dom manipulation is being detected. Would be interesting to know what could be done serverside to know which is the default choice for scripts (html embeds?) |
More related discoveries that trigger the same error. I have some simple JavaScript that handles my nav button. Showing and hiding the main menu. I've got this in a HTML embed that I've copied across every page. This works on first load but when navigating to any page, this script fails with the same error.
There's definitely something fruity going on with scripts and how they are loaded/handled. One small indication is the fading in/out of the menu of my pages. It jitters. Which is normally an indication of gsap code firing a couple of times which syncs up with the "already declared" message. Live in progress website: https://x-new-worlds-mttq5.wstd.io/ |
Mostly server-side is useful for some html/css, 90% of scripts are manipulating dom. Problem is we can't know for sure. |
https://docs.webstudio.is/university/core-components/html-embed#avoid-creating-global-variables |
Maybe we could auto-set type module on scripts ... |
@kof thank you. issue with auto Wording was perfect in the tooltip, it's just knowing what it's there for. Another alternative could be forcing the user to choose client or server side on creation before they are able to add code (still able to switch after the fact) or separate server HTML embed component entirely. It's a neat feature just with a few hidden quirks to use it. |
@kof jittering is my bad. I had a weird easing on the animation. Doh! |
Seems like all things resolved here |
The task is, create a video element on the page for each item in a collection that has the url of a video as an attribute.
Unless I'm going mental this bit of code loops through all the elements with a data-video=url on them, creates a video element, with a source using the url and adds it to the page.
When I add the HTML to the page inside the currently iterated item, it breaks with the error.
SyntaxError: Identifier 'instagramVideos' has already been declared
Link to project: https://apps.webstudio.is/builder/b851928d-a587-4b95-bdfd-24f3acf13770?authToken=23b21aa4-5071-4fe5-b7df-d07a10861586&mode=preview
The text was updated successfully, but these errors were encountered: