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

Two-way bound attribute watcher not appearing dirty when it should #9821

Closed
darabos opened this issue Oct 29, 2014 · 8 comments
Closed

Two-way bound attribute watcher not appearing dirty when it should #9821

darabos opened this issue Oct 29, 2014 · 8 comments

Comments

@darabos
Copy link

darabos commented Oct 29, 2014

This example probably does a better job of describing the issue than I could: http://jsfiddle.net/ne74rdhg/ When you first click the button, the text does not appear. It appears on a second click. If you switch the same example from 1.3.0-beta.16 to 1.3.0-beta.15, the button works as expected.

I spent some time looking into the issue, so let me write down my findings. But I'm not familiar with Angular's insides, so feel free to disregard my ramblings :).

The issue appears after @rodyhaddad 's 86d55c1. The commit has changed how nodeLinkFn creates a watcher for =. parentValueWatch has become an interceptor. addInterceptor is strange in that it will always return the pre-interceptor value if it was undefined.

In my JSFiddle greeting starts out undefined. When it changes, parentValueWatch copies it up into the controller's scope and returns the new value. But interceptedExpression still returns undefined, because the value was undefined before running the interceptor. So the watcher is not dirty (it went from undefined to undefined), digest stops, and the change does not propagate into text.

@lgalfaso
Copy link
Contributor

it looks like a real bug

lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Oct 29, 2014
When using `$parse` with a stateful interceptor and the expression
is `undefined`, then return the result from the interceptor

Closes angular#9821
@lgalfaso lgalfaso removed their assignment Oct 29, 2014
lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Oct 29, 2014
When using `$parse` with a stateful interceptor and the expression
is `undefined`, then return the result from the interceptor

Closes angular#9821
lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Oct 29, 2014
When using `$parse` with a stateful interceptor and the expression
is `undefined`, then return the result from the interceptor

Closes angular#9821
@caitp
Copy link
Contributor

caitp commented Oct 29, 2014

@lgalfaso this bug is bogus. The issue is that in the reproduction, the wrong attribute name is used in the binding outside of the isolate scope

@caitp
Copy link
Contributor

caitp commented Oct 29, 2014

--- actually, I'm half-wrong. The repro is bogus, but it is still slightly broken, I just didn't notice =)

@lgalfaso
Copy link
Contributor

@caitp in the parent scope, there is a watcher $scope.$watch('greeting', function(greeting) { $scope.text = greeting; });

@caitp
Copy link
Contributor

caitp commented Oct 29, 2014

The reason why that wouldn't work is because the controller (and watch) is instantiated (and run) first, and we aren't going back to re-check it. It fails with the other case as well, which is the problem.

@lgalfaso
Copy link
Contributor

@caitp you are right, this is still an issue without the second external watch as in http://jsfiddle.net/8c2qekz4/

lgalfaso added a commit to lgalfaso/angular.js that referenced this issue Oct 29, 2014
When using `$parse` with a stateful interceptor and the expression
is `undefined`, then return the result from the interceptor

Closes angular#9821
@Narretz Narretz added this to the 1.3.1 milestone Oct 29, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.1, 1.3.2 Oct 31, 2014
@petebacondarwin
Copy link
Contributor

@IgorMinar - any update on this? :-)

@IgorMinar
Copy link
Contributor

looking now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.