Skip to content
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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open

Conversation

Strajk
Copy link
Contributor

@Strajk Strajk commented Apr 3, 2024

Pilulka took the SPA pill

Screenshot-2024-04-03T13.42.09.mp4

@Strajk Strajk marked this pull request as ready for review April 3, 2024 11:44
lib/parse.mjs Show resolved Hide resolved
Copy link
Collaborator

@rarous rarous left a 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));
Copy link
Collaborator

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rarous @Strajk Can we revive this thread and complete the fix? I tried to fix it in e8486d0 unaware of this existing PR, but obviously, the extension still fails to render with my solution in some cases...

Copy link
Collaborator

@rarous rarous Nov 12, 2024

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants