-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX canary] Prevent unknown input types from erroring. #10690
Conversation
return type; | ||
} | ||
|
||
var input = document.createElement('input'); |
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.
we should likely just create this element once, not once per cache miss.
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.
Good point, done.
35cbe29
to
8d6b2f7
Compare
Browsers support various values for `type`, and generally auto-correct to just `"text"` if an unknown type is set via standard HTML. Unfortunately, the same auto-correct behavior does not apply when setting the attribute directly, and in some circumstances throw an error where the type is not valid. Specifically, the following throws an error in IE10: ```javascript var e = document.createElement('input'); e.type = 'search'; ``` However the following HTML would auto-correct to `"text"`: ```html <input type="search"> ```
8d6b2f7
to
7526d1f
Compare
LGTM |
[BUGFIX canary] Prevent unknown input types from erroring.
Thanks Robert. |
@rwjblue I think this can actually be pulled out if tildeio/htmlbars#355 lands and input#type is added to the list of bad pairs to use |
C |
Browsers support various values for
type
, and generally auto-correct to just"text"
if an unknown type is set via standard HTML.Unfortunately, the same auto-correct behavior does not apply when setting the attribute directly, and in some circumstances throw an error where the type is not valid.
Specifically, the following throws an error in IE10:
However the following HTML would auto-correct to
"text"
:This PR adds a feature detect to see if a given type can be set to
input
. If setting the type results in the value, then we use it otherwise we default to"text"
.Fixes #10458.