Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Attributes/Converters Issue #174
Using the attributes plugin, I have an attribute of a model that is another type of model. And then an attribute of that second model uses a converter to determine its value.
In my app, it polls the server for fresh data and uses live binding to update the data in view. I noticed that a value that is determined using a converter is wrong after the first go round. It actually seems to be calling the converter twice. The first time with the correct value from the server, and the second time with the converted value. The second (incorrect) value is what is being used.
Please see the following fiddle. To simulate polling, just double click the output frame.
Looking at commits, it seems that the issue was introduced with this commit:
referenced this issue
Jan 4, 2013
Tested this against latest locally and its no longer breaking. Tomorrow we'll push out a new 1.1.4 release candidate at http://canjs.us/release/latest/can.jquery.js (this isn't currently actually pushing out every night automated) and this should confirm this issue is fixed.
Actually nevermind what I said above, forgot I had made a local change. Actually these lines in observe.js cause this weird behavior:
__convert is called twice per nested observe, once here and once a few lines down at self._set(prop, newVal). I'm not sure why this was necessary.
f9896d9 introduced this line.
Commenting these lines out fixes this issue and all other can tests still pass. Will talk to @imjoshdean about this tomorrow and get a test in.