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
Ensure preact/compat is not converting onchange to oninput for input type="range" in IE11 #2817
Ensure preact/compat is not converting onchange to oninput for input type="range" in IE11 #2817
Conversation
onchange
to oninput
for input type="range" in IE11
onchange
to oninput
for input type="range" in IE11There 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.
Good catch, this is great! Let's add a quick unit test to make sure we don't regress on this in the future. Our suite runs tests in all browsers including IE11 automatically, so a test where we test if a value was changed should do the job 👍
Thanks for taking a look at this @marvinhagemeister. To clarify on the test coverage, we could amend the existing test: preact/compat/test/browser/events.test.js Lines 73 to 85 in 9aa7d38
Symbol polyfill when it is ran in IE11. That would replicate the problematic scenario we're guarding against. But I'm not sure if that's the same as what you were suggesting.
I'm happy to add the test, just looking for clarification. Thanks! |
@gcraftyg yup, that sounds perfect. Either way, amending or adding a new test is fine, as long as we have something that checks for it in the CI 👍 |
I pushed up a test that guards against the regression. In order to polyfill My preference would be to keep it as a variable, but I'm not aware of a way to inject a polyfill for a specific test before the module is imported. |
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.
Sweet, the test is perfect! Thank you so much for your PR 🙌
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.
Awesome, thank you so much!
When using preact/compat, an input of
type="range"
converts anonchange
tooninput
except in IE11. This mimics react's implementation asoninput
will not fire on an<input type="range" />
in IE11.I came across a situation where I was not seeing the
onChange
prop firing in IE11. Looking at it closer, preact/compat detects IE11 by checkingtypeof Symbol != 'undefined'
. This works well as long asSymbol
is not being polyfilled, for instance in a NextJS app with preact.This PR is adding an additional check to verify that
Symbol
is native to the browser and not polyfilled, allowing for<input type="range" />
to behave as expected.