MoOx / pjax

Easily enable fast Ajax navigation on any website (using pushState + xhr)
MIT License
1.46k stars 125 forks source link

Pjax is not working on mobile firefox. #180

Closed venzersiz closed 5 years ago

venzersiz commented 6 years ago

Hi, I have a problem. I'm making mobile web app using pjax. and then testing cross browsing. But only mobile firefox, pjax is not working.

I debugged library's codes and found a part that cause problem.

In bundle js file, line 711

        window.history.replaceState({
                url: currentState.url || window.location.href,
                title: currentState.title || document.title,
                uid: currentState.uid || newUid(),
                scrollPos: [document.documentElement.scrollLeft || document.body.scrollLeft,
                    document.documentElement.scrollTop || document.body.scrollTop]
            },
            document.title, window.location)

I tried catch the exception, then alert the message.

The message was 'DataCloneError: The object can not be cloned.'

After caught the exception, pjax is working.

Do you know why does this problem occurred?


pjax version: 0.2.5, 0.2.7 device: iPhone 7 / 8 iOS version: 12.0 (16A366) mobile firefox version: 14.0 (12646)

BehindTheMath commented 6 years ago

Can you give some more details about what's not working? Or better yet, can you provide a codepen reproducing the issue?

venzersiz commented 6 years ago

Hi, I found an article. I tested and checked that the codes work properly.

I checked that 'history.replaceState' function's parameters. Third parameter requires optional url. It might be String type. But in pjax codes, it passes 'window.location' object. I think that should be 'window.location.href'.

In a [Mozilla's article](https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_replaceState()_method), they noticed the following.

Note: In Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) through Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2), the passed object is serialized using JSON. Starting in Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3), the object is serialized using the structured clone algorithm. This allows a wider variety of objects to be safely passed.

I think that by any chance, the algorithm might cause the problem.

How do you think?

BehindTheMath commented 6 years ago

You are probably correct that your error is caused by that algorithm. However, that has nothing to do with the url parameter; it's only used for the state parameter. Looking at the Pjax source, I don't see anything that would cause the error.

Can you post or link to your full code?

venzersiz commented 6 years ago

Ok. So I'll give you the link for test. It also related to issue #182 . But I can't find your email address. Can you give me your email address? Or if you don't like to be discovered your email publicly, just send an contentless email me. then I will send an email with the link.

Thank you!

BehindTheMath commented 6 years ago

This appears to be a bug in Firefox. I'm not sure why it's only in Firefox, since all browsers on iOS use WebKit.

Regardless, we can pass window.location.href instead of window.location, like you suggested here

venzersiz commented 6 years ago

OK. Do you have a plan to change the codes?

BehindTheMath commented 6 years ago

Hopefully I can do that soon, but it will take time until a new release is pushed out to NPM.

venzersiz commented 6 years ago

OK, thank you. I'll wait.

venzersiz commented 6 years ago

What about #182? Have you been testing it?

BehindTheMath commented 5 years ago

This issue should be fixed by #191. I would have made it a separate commit and PR, but it accidentally got included in that one.

There's still no timeline on when a new version will be pushed to npm.