Pjax is not working on mobile firefox. #180

Closed
opened 2018-10-31 01:43:42 -05:00 by venzersiz · 10 comments
venzersiz commented 2018-10-31 01:43:42 -05:00 (Migrated from github.com)

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)

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 2018-11-11 16:07:48 -05:00 (Migrated from github.com)

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

Can you give some more details about what's not working? Or better yet, can you provide a codepen reproducing the issue?
venzersiz commented 2018-11-13 00:39:40 -05:00 (Migrated from github.com)

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, 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?

Hi, I found an [article](https://stackoverflow.com/questions/27558398/datacloneerror-the-object-could-not-be-cloned-in-firefox-34). 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 2018-11-21 22:01:10 -05:00 (Migrated from github.com)

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?

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 2018-11-21 23:48:35 -05:00 (Migrated from github.com)

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!

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 2018-11-25 23:17:37 -05:00 (Migrated from github.com)

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

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](https://github.com/MoOx/pjax/issues/180#issuecomment-438143679)
venzersiz commented 2018-11-26 04:08:31 -05:00 (Migrated from github.com)

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

OK. Do you have a plan to change the codes?
BehindTheMath commented 2018-11-26 09:14:40 -05:00 (Migrated from github.com)

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

Hopefully I can do that soon, but it will take time until a new release is pushed out to NPM.
venzersiz commented 2018-11-26 19:33:51 -05:00 (Migrated from github.com)

OK, thank you. I'll wait.

OK, thank you. I'll wait.
venzersiz commented 2018-11-26 19:35:18 -05:00 (Migrated from github.com)

What about #182? Have you been testing it?

What about #182? Have you been testing it?
BehindTheMath commented 2019-03-03 12:39:31 -05:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#180