-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(attrs): trigger observers for specific ng-attributes #7758
Conversation
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() { |
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 don't understand what this test is saying is happening. did you misspell ng-maxlength
?
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.
Yes. Fixed.
if (match) { | ||
var regexp = new RegExp(match[1], match[2]); | ||
return function() { | ||
return regexp; |
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 function is missing constant / literal markers
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 mean the name of the function?
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.
Functions returned by $parse have a constant and literal property on them (docs for it)
I believe they're both true in this case
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'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
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.
So what exactly should I fix then?
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.
a simple fix would be this:
return extend(function() {
return regexp;
}, {
constant: true,
literal: false // or true? depending on how people feel about it
});
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 so these are special flags used within the internals of the parser?
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.
yeah, $scope will automatically unwatch a constant expression, and I think we use literal in ngClass or something, can't remember
…ly instantiate regular expressions Closes angular#7758
@@ -472,6 +478,11 @@ function getBooleanAttrName(element, name) { | |||
return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr; | |||
} | |||
|
|||
function getAliasedAttrName(element, name) { | |||
var nodeName = element.nodeName; |
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 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
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.
or check for nodeType
instead.
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
Landed as d9b90d7 |
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
No description provided.