Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngList):Make ngList work with input of type email, url #4549

Closed
wants to merge 1 commit into from
Closed

fix(ngList):Make ngList work with input of type email, url #4549

wants to merge 1 commit into from

Conversation

sudodoki
Copy link

Validity for inputs are checked for single value using static regexp, which won't work with ngList directive on the input, since it's getting us an array of attributes.

Just like [https://github.com//pull/4295], but introducing every helper function, just as I mentioned at my last comment there.

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

ctrl.$parsers.push(function(value) {
var empty = ctrl.$isEmpty(value);
if (empty || NUMBER_REGEXP.test(value)) {
if (empty || NUMBER_REGEXP.test(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem necessary

@sudodoki
Copy link
Author

@caitp thanks for feedback, changed this according to your comments.

@@ -4,6 +4,16 @@ var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\
var EMAIL_REGEXP = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/;
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;

function every(array, fun) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing though, because this is kind of a helper, it may be suitable to add it to src/Angular.js, along with the others. Even if it's not made public, it might help prevent similar additions from being added to other source files. Once triaged I'm sure the core team will have their own things to say about all of it

Validity for inputs are checked for single value using static regexp, which won't work with ngList directive on the input, since it's getting us an array of attributes.
@sudodoki
Copy link
Author

Thanks @caitp once again. Updated PR.

@redconfetti
Copy link

If #4295 was closed in favor of #4549, then why was it closed also?

@sudodoki
Copy link
Author

then why was it closed also?

It isn't, in fact.

@mary-poppins seems not to like the commit mesage, though it's copy of my previous one, that passed the check in #4295, same for the Contributor signed CLA checkbox.

@sudodoki
Copy link
Author

sudodoki commented Feb 4, 2014

This kinda went stale, should I update it?

@redconfetti
Copy link

I'm really confused how this isn't in fact closed. I'd say yes, update it.

@RichardLitt
Copy link
Contributor

Is there any movement on this? What's needed next to merge it in?

RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 20, 2014
…nput. It returns a string, not an array, but should be included as valid HTML and validated by Angular. angular#4549
RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 20, 2014
@RichardLitt
Copy link
Contributor

@caitp Do you know why every is failing in Travis? I pushed a second commit to fix my sloppy semicolon errors, but I'm not sure how to push that into the same PR, and I can't figure out why every is failing...

RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 21, 2014
@caitp
Copy link
Contributor

caitp commented Apr 21, 2014

@RichardLitt The last build is failing because of jshint/jscs errors.

You can see them locally if you run grunt ci-checks

var urlValidator = function(value) {
if (ctrl.$isEmpty(value) || URL_REGEXP.test(value)) {
if (isArray(value)) {
testedValid = every(value, function(val){return URL_REGEXP.test(val)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a semicolon after return URL_REGEXP.test(val)

RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 21, 2014
@RichardLitt
Copy link
Contributor

@caitp Thanks a lot! Edited those, declared every in the jshint area in build/angular.js. I'm not running into any errors locally if I run grunt ci-checks, but I wasn't before either, so I'm not sure what the deal is.

RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 21, 2014
RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 21, 2014
RichardLitt added a commit to RichardLitt/angular.js that referenced this pull request Apr 27, 2014
@Narretz
Copy link
Contributor

Narretz commented Jun 23, 2014

when this finally lands, this will also close #4185

@sudodoki
Copy link
Author

At the moment, I would suggest marking this as a known issue and just moving on to implement support for multiple attribute to work with email/url inputs, which would be more according to standards, which seems to be more angular-wayish.

@sudodoki sudodoki closed this Jul 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants