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

polyfill padStart/padEnd in mobile Safari #414

Closed
gulping opened this issue Jul 9, 2018 · 0 comments
Closed

polyfill padStart/padEnd in mobile Safari #414

gulping opened this issue Jul 9, 2018 · 0 comments
Labels

Comments

@gulping
Copy link

gulping commented Jul 9, 2018

summary

#280
padStart/padEnd is buggy in some versions of Safari.
polyfill of core-js is available in the desktop Safari.
I encountered the bug in the mobile Safari so please polyfill in the mobile too.


I just encountered the bug.
I'll try to refine the reproductive environment and working example when you request.

I'm using core-js via babel.

iOS version

It happens in iOS 10.2.1,
It doesn't happen in iOS 8.x, 9.x, 10.3.x, 11.x,
(as far as I tested)

situation when I encountered it

fetch serial zero-padded number files.

// pseudo code
[0, 1, 2, ...].forEach( number => {
  const padded = `${number}`.padStart(4, "0"); // "0000", "0001", ...
  fetch(`https://..../${padded}.json`).then(do some processes);
});

This runs successfully.
But run about 20+ fetches in parallel, padStart returns buggy result("null0", "null1", ...).

workaround

I read #280,
and I thought that the RegExp test
/Version\/10\.\d+(\.\d+)? Safari\//
only matches to desktop Safari.

the example of userAgent of mobile Safari
Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1

So I just added .* as workaround.
/Version\/10\.\d+(\.\d+)?.* Safari\//
And it runs successfully.


so it seems to fix when polyfill in the mobile too.

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

No branches or pull requests

2 participants