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

ngStyle one-time binding regression #11403

Closed
Narretz opened this issue Mar 23, 2015 · 4 comments
Closed

ngStyle one-time binding regression #11403

Narretz opened this issue Mar 23, 2015 · 4 comments

Comments

@Narretz
Copy link
Contributor

Narretz commented Mar 23, 2015

There's a regression in ngStyle that breaks lazy one-time binding (when a property value is initially undefined), caused by 4c8d8ad

Example: http://jsbin.com/tuyetahaxi/2/edit - change the version to 1.3.9, and the background-color will not be applied.

The cause for this break is that $watchCollection passes its own changeDetector function to $watch, which does not return the actual changed values, but only a changeDetected counter. However, $parse has a special path for one-time bound object literals, where it unwatches only when all object properties / array elements are defined (see c024f28). With watchCollection, the binding watch is now removed instantly as the value that is passed to $watch is not the actual object / array but the changeDetected count from $watchCollection.
I worked around this by returning the actual newValue / oldValue from inside $watchCollection's changeDetected. I'll have to test if this breaks anything, though.

@daldegam
Copy link

+1

@lgalfaso
Copy link
Contributor

it looks like 4c8d8ad was simply wrong and should be reverted.
PR (with a test) welcome

Narretz added a commit to Narretz/angular.js that referenced this issue Mar 23, 2015
This reverts commit 4c8d8ad, because
it broke lazy one-time binding for object literals
(introduced in c024f28)

Fixes angular#11403
Narretz added a commit that referenced this issue Mar 31, 2015
This reverts commit 4c8d8ad, because
it broke lazy one-time binding for object literals
(introduced in c024f28)

Fixes #11403
@mgol
Copy link
Member

mgol commented Mar 31, 2015

Shouldn't the revert add a test as well?

@Narretz
Copy link
Contributor Author

Narretz commented Mar 31, 2015

The test was added in the commit before the revert. Not ideal, but hey. I thought I added it after it.

----- Ursprüngliche Nachricht -----
Von: "Michał Gołębiowski" [email protected]
Gesendet: ‎31.‎03.‎2015 14:03
An: "angular/angular.js" [email protected]
Cc: "Martin Staffa" [email protected]
Betreff: Re: [angular.js] ngStyle one-time binding regression (#11403)

Shouldn't the revert add a test as well?

Reply to this email directly or view it on GitHub.

netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
This reverts commit 4c8d8ad, because
it broke lazy one-time binding for object literals
(introduced in c024f28)

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

No branches or pull requests

4 participants