-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix Pilulka.{cz,sk} widget #2079
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change setTimeout to mutation observer of given element
const product = data.find(x => x["@type"] === "Product"); | ||
// Give Nuxt 100ms to replace the json-ld script tag with correct data, | ||
// otherwise it could contain old product when using SPA navigation | ||
await new Promise(resolve => setTimeout(resolve, 100)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, wait for the observed change of element. Don't introduce arbitrary race conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There has to be MutationObserver
waiting for the change of the JSON+LD script. IIRC StatefulShop
can be used for this, I think Mall.cz had something similar and might be used as inspiration at least for mechanics. Hard-coded time will break on slow devices...
Pilulka took the SPA pill
Screenshot-2024-04-03T13.42.09.mp4