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
Update SubmitEvent Polyfill to Workaround Safari 15 bug #405
Conversation
ac6a272
to
1071254
Compare
1071254
to
51e39a8
Compare
@dhh ok I manually tested the broken behavior using Safari 15 with |
cc @ParamagicDev since you use a similar polyfill for your mrujs project. |
Thank you @terracatta , making a note on Mrujs so I can hotfix this. |
Do we need any additional verification that this didn’t break other browsers handling it? Will this automatically become irrelevant when safari is fixed or does it require a change then? |
I don't think so. First, the way it's written I only run a new behavior if it's Safari (via testing the Second, I've been running my ES6 polyfill on a high-traffic app that generates exceptions for console errors, and I am not seeing any regression in browsers that were already working fine.
So I downloaded the latest Safari Technical Preview I cannot think of a clean way to test if we are on the fixed version of Safari without actually creating a fake form that produces the bug, submitting it via JS, preventing default, and checking the value of submitter. This might be possible, but I'm not sure if the juice is worth the squeeze. |
Great work. Let’s put a note to revisit this in 3 months or whatever and hope that the version in the wild no longer is a meaningful percentage so we can clean this up 👍 |
// Certain versions of Safari 15 have a bug where they won't | ||
// populate the submitter. This hurts TurboDrive's enable/disable detection. | ||
// See https://bugs.webkit.org/show_bug.cgi?id=229660 | ||
if ("SubmitEvent" in window && /Apple Computer/.test(navigator.vendor)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly question, since Safari on iOS is probably similar to desktop Safari, is there a chance this will need to be fixed when iOS 15 ships?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appears navigator.vendor can only be one of:
"Google Inc."
, "Apple Computer Inc."
, or ""
So I think we should be okay (you also tested it as well, thank you!)
Fixes #390
This PR updates the Polyfill to work around the Safari 15 bug where the submitter property is sometimes null when a form is submitted with element of type button vs an element of type submit. More info https://bugs.webkit.org/show_bug.cgi?id=229660