-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
In some cases we need to dynamically write out the script tag for grid-gallery.js (e.g., when used in modals). In this case, if the container is destroyed and recreated, it will throw an "Uncaught SyntaxError: Identifier 'root' has already been declared" error because the constant root
is still in memory.
Steps to reproduce:
- Go to https://codepen.io/thdoan/pen/yLjjLPw
- Launch the modal
- Close the modal (click on empty space below)
- Launch the modal
- Observe the JS error in the console
Fix: wrap everything in an IIFE to preserve variable scope.
(() => {
const root = document.querySelector("body, html");
...
})();
ssntihobs
Metadata
Metadata
Assignees
Labels
No labels