PaperStrike / Pjax

Easily enable fast AJAX navigation (Fetch + pushState)
MIT License
24 stars 3 forks source link

Pjax fails when dealing with meta tags with dynamically added tags. #430

Open Yahav opened 11 months ago

Yahav commented 11 months ago

Describe the bug

Please look at the following: https://github.com/PaperStrike/Pjax/discussions/429

To reproduce

No response

Expected behavior

No response

Environment

- OS:
- Browser:
- Pjax:

Anything else?

No response

PaperStrike commented 11 months ago

You may try to use more specific selectors like meta[name=foo] or with exclusion like meta:not([name=bar]), or custom switches described in https://github.com/PaperStrike/Pjax/discussions/429#discussioncomment-7175102 . Would these be able to solve your issue?

Yahav commented 11 months ago

Wouldn't work since i don't have head as a selector, when it is the automatic script execution causes issues . one example is when a script tag is added by another script after the dom switch but before preparePage the it's executed twice which causes all kind of issue. i'm handling all the scripts execution myself with hooks, far more flexible.

I still think that since meta are unique tags they should be handled differently (as i stated at the discussion)

PaperStrike commented 11 months ago

Wouldn't work since i don't have head as a selector

So why not use a head selector?

PaperStrike commented 11 months ago

one example is when a script tag is added by another script after the dom switch but before preparePage the it's executed twice which causes all kind of issue.

Are you adding script tags in the switchesResult hook? What exact scenario is this for? Most of the time these operations should be done in a pjax:success/pjax:complete event callback.