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

fix($parse): handle constants as one-time binding expressions #7970

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

Handle constant expressions as one-time binding expressions.
Avoids the infinite digest from
https://github.com/angular/angular.js/pull/7960/files#r14136938

Handle constant expressions as one-time binding expressions.
Avoids the infinite digest from
https://github.com/angular/angular.js/pull/7960/files#r14136938
@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#7970)

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!

@IgorMinar
Copy link
Contributor

Lgtm


expect($rootScope.$$watchers.length).toEqual(0);
}));

Copy link
Member

Choose a reason for hiding this comment

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

Maybe objects/arrays containing references to scope should be tested so that we don't lose bindings to them? Or is it already covered?

Copy link
Contributor

Choose a reason for hiding this comment

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

"references to scope"? can you provide an example?

Copy link
Member

Choose a reason for hiding this comment

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

Something along the lines:

var handledFoo;
$rootScope.foo = 'bar';
$rootScope.$watch('[2, foo, "c"]', function(value) {
    handledFoo = value[1];
}, true);
$rootScope.$digest();
expect(handledFoo).toBe('bar');
$rootScope.foo = 'baz';
$rootScope.$digest();
expect(handledFoo).toBe('baz');

I guess other tests can be already checking that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that really testing if $parse reports [2, foo, "c"] as a constant or not?

Copy link
Member

Choose a reason for hiding this comment

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

@rodyhaddad Yes, basically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mzgol you cannot watch a non-constant literal expression without specifying objectEquality = true without triggering a digest issue. This was the case before the one-time binding patch and now

Copy link
Member

Choose a reason for hiding this comment

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

ok

@rodyhaddad
Copy link
Contributor

LGTM

@lgalfaso lgalfaso closed this in d9763f1 Jun 25, 2014
ckknight pushed a commit to ckknight/angular.js that referenced this pull request Jul 16, 2014
Handle constant expressions as one-time binding expressions.
Avoids the infinite digest from
https://github.com/angular/angular.js/pull/7960/files#r14136938

Closes angular#7970
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