-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(input): apply directives to only suitable inputs #6243
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ var inputType = { | |
</doc:example> | ||
*/ | ||
'text': textInputType, | ||
'textarea': textInputType, | ||
|
||
|
||
/** | ||
|
@@ -419,12 +420,7 @@ var inputType = { | |
</doc:protractor> | ||
</doc:example> | ||
*/ | ||
'checkbox': checkboxInputType, | ||
|
||
'hidden': noop, | ||
'button': noop, | ||
'submit': noop, | ||
'reset': noop | ||
'checkbox': checkboxInputType | ||
}; | ||
|
||
// A helper function to call $setValidity and return the value / undefined, | ||
|
@@ -830,8 +826,11 @@ var inputDirective = ['$browser', '$sniffer', function($browser, $sniffer) { | |
require: '?ngModel', | ||
link: function(scope, element, attr, ctrl) { | ||
if (ctrl) { | ||
(inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer, | ||
$browser); | ||
var type = element.prop('type'); | ||
|
||
if (inputType[type]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the lowercase call? input types are case insensitive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not have, my mistake. Chrome at least returns a lowercase string for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it "sort of" works for this case because you're using the property rather than the attribute, but my comment above explains why this can be a problem (for legacy browsers). @Blesh's date stuff is probably also going to be a problem if this change happens, due to modern desktop FF (among others) not supporting html5 date input types. |
||
inputType[type](scope, element, attr, ctrl, $sniffer, $browser); | ||
} | ||
} | ||
} | ||
}; | ||
|
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.
What? Afaik there is no
input[type=textarea]
, only the textarea element.We want to use textInputType for textarea elements, so...
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.
You're right, but at least in chrome (the only browser I tested with), the "type" property of a <textarea> is "textarea". This directive is applied to
<textarea>
elements as well as<input>
elements, so this was added to catch those.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.
ah I see. I'm not totally sure if that will work for IE, but I guess we'll see. (In review I usually scan the diff from top to bottom, hadn't noticed you were using the property rather than attribute yet ;)