-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(input): support multiple attribute for email #8987
Conversation
Closes #6032 |
Not sure if |
src/ng/directive/input.js
Outdated
return ctrl.$isEmpty(value) || EMAIL_REGEXP.test(value); | ||
if (!ctrl.$isEmpty(value)) { | ||
value = attr.multiple ? value.split(/\s*,\s*/) : [value]; | ||
for (var i = 0; i < value.length; i++) { |
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.
I would really like to use Array.prototype.every
here instead of this for
loop. Since IE8 is no longer supported, can we do that?
Honestly, I'd love to have a more robust solution for this that works with all (text-based)-inputs similar to ngList (which exposes an array). I don't know what the HTML spec says about delimiters, supported input types etc. though. Is this really all the information there is: http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#attr-input-multiple? |
afaik the multiple attribute is only relevant for email and file inputs. On Tue, Sep 9, 2014 at 1:00 PM, Narretz notifications@github.com wrote:
|
some references... supported only for email and file: comma separated: |
Only supported for email, how odd! |
Sounds reasonable, I'll look into it. |
I've refactored this to expose an array and keep the array validation not specific to emails. I think it is hackish and ugly though. Would welcome some suggestions. |
src/ng/directive/input.js
Outdated
runProcessor(processAsyncValidators); | ||
|
||
function runProcessor(fn) { | ||
if ($attr.multiple && isArray(modelValue) && nodeName_($element) !== 'select') { |
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.
this condition can be easily changed to work with ngList as well, but it is a pretty big breaking change, so I'm not sure...
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.
the nice thing about getting this into ngList as well is obviously that we could use validators like ngPattern, maxlength, etc. which currently don't work correctly with ngList
02dc2aa
to
fd2d6c0
Compare
@shahata - a cool bit of works as usual. I like the idea of reusing the How about we factor out the Any thoughts? |
@petebacondarwin - I've refactored this a bit more, so |
var normalized = directiveNormalize('ng-' + attrName); | ||
ngAttributeAliasDirectives[normalized] = function() { | ||
return { | ||
restrict: 'A', | ||
priority: 100, | ||
link: function(scope, element, attr) { | ||
// binding to multiple is not supported for select | ||
if (propName === 'multiple' && nodeName_(element) === 'select') { |
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.
had to do this in order to reinstate ngMultiple for non-select elements (it is unsupported for select elements since d87fa00)
@shahata - sorry I haven't got around to looking at this again yet |
cad9560
to
f294244
Compare
8292c21
to
7b9fddf
Compare
I know that angular don't support file input (coz of #1375) @petebacondarwin if something like file input would even make use of this multiple-directive/service/helper function (in a custom directive or by angular itself in some future), I'm guessing the modelValue would be equal to Wouldn't like there to be any conflict by other element using the multiple attribute in any other ways |
4dd5a20
to
998c61c
Compare
bump |
ba da bump |
I am currently working on this. |
Closes #8986