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

feat(attrs): trigger observers for specific ng-attributes #7758

Closed
wants to merge 1 commit into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Jun 9, 2014

No description provided.

@mary-poppins
Copy link

I envy the poor soul who will have to review this

@@ -1148,6 +1188,20 @@ describe('input', function() {
changeInputValueTo('aaa');
expect(scope.value).toBe('aaa');
});

it('should listen on ng-minlength when maxlength is observed', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what this test is saying is happening. did you misspell ng-maxlength?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Fixed.

@matsko matsko added cla: yes and removed cla: no labels Jun 9, 2014
if (match) {
var regexp = new RegExp(match[1], match[2]);
return function() {
return regexp;
Copy link
Contributor

Choose a reason for hiding this comment

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

this function is missing constant / literal markers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean the name of the function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Functions returned by $parse have a constant and literal property on them (docs for it)

I believe they're both true in this case

Copy link
Contributor

Choose a reason for hiding this comment

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

we're only using literal for JSON literals currently, so it's not clear if it should include regexp literals too, but it's definitely constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So what exactly should I fix then?

Copy link
Contributor

Choose a reason for hiding this comment

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

a simple fix would be this:

return extend(function() {
  return regexp;
}, {
  constant: true,
  literal: false // or true? depending on how people feel about it
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah so these are special flags used within the internals of the parser?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, $scope will automatically unwatch a constant expression, and I think we use literal in ngClass or something, can't remember

matsko added a commit to matsko/angular.js that referenced this pull request Jun 9, 2014
@@ -472,6 +478,11 @@ function getBooleanAttrName(element, name) {
return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr;
}

function getAliasedAttrName(element, name) {
var nodeName = element.nodeName;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if we still need it for IE9, but there is _nodename helper method to get name in a cross browser happy way

Copy link
Contributor

Choose a reason for hiding this comment

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

or check for nodeType instead.

matsko added a commit to matsko/angular.js that referenced this pull request Jun 10, 2014
When an observer is set to listen on the pattern, minlength or maxlength attributes
via $attrs then the observer will also listen on the ngPattern, ngMinlength and the
ngMaxlength attributes as well.

Closes angular#7758
When an observer is set to listen on the pattern, minlength or maxlength attributes
via $attrs then the observer will also listen on the ngPattern, ngMinlength and the
ngMaxlength attributes as well.

Closes angular#7758
@matsko matsko changed the title feat(parser): automatically observe aliased ng- attributes and natively instantiate regular expressions feat(attrs): trigger observers for specific ng-attributes Jun 10, 2014
@matsko matsko closed this in d9b90d7 Jun 10, 2014
@matsko
Copy link
Contributor Author

matsko commented Jun 10, 2014

Landed as d9b90d7

@matsko matsko deleted the implicit_ng_attrs branch June 10, 2014 01:49
matsko added a commit to matsko/angular.js that referenced this pull request Jun 10, 2014
When an observer is set to listen on the pattern, minlength or maxlength attributes
via $attrs then the observer will also listen on the ngPattern, ngMinlength and the
ngMaxlength attributes as well.

Closes angular#7758
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants