[ALOY-1479] Regression: Model instance data binding no longer works
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-03-30T21:20:19.000+0000 |
Affected Version/s | alloy 1.8.3, alloy 1.8.4 |
Fix Version/s | Release 5.2.2, alloy 1.8.4, alloy 1.8.5 |
Components | Models |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Fokke Zandbergen |
Created | 2016-03-30T13:41:20.000+0000 |
Updated | 2016-03-31T23:27:44.000+0000 |
Description
Data binding of local model instances throws an exception in Alloy 1.8.3 and 1.8.4 because of [this line change](https://github.com/appcelerator/alloy/pull/769/files#diff-a59a2178e486f81366775c39e5393695L521) to resolve ALOY-1369.
*XML*
<Label top="20" text="{$.modelinstance.foo}" />
<Label text="{$.modelinstance.foo} {$.modelinstance.bar}" />
*compiled*
$.__alloyId4.text = _.template("{$.modelinstance.foo}", {
modelinstance: transformed
}, {
interpolate: /\{([\s\S]+?)\}/g
});
$.__alloyId5.text = _.template("{$.modelinstance.foo} {$.modelinstance.bar}", {
modelinstance: transformed
}, {
interpolate: /\{([\s\S]+?)\}/g
});
/cc [~cng] [~emerriman] [~fmiao]
I'm including a test app that covers all of the following cases:
Simple global model data binding
Complex global model data binding
Complex global model data binding with undefined model attribute
Simple local model instance data binding
Complex local model instance data binding
Complex local model instance data binding with undefined model attribute
Simple global collection data binding
Complex global collection data binding
Complex global collection data binding with undefined model attribute
Simple local collection instance data binding
Complex local collection instance data binding
Complex local collection instance data binding with undefined model attribute
Simple global collection data binding in required view
Complex global collection data binding in required view
Complex global collection data binding in required view with undefined model attribute
Simple local collection instance data binding in required view
Complex local collection instance data binding in required view
Complex local collection instance data binding in required view with undefined model attribute
The following cases are already covered by the test app for ALOY-1474:Simple global model data binding
Complex global model data binding
Simple global model data binding with model transform method
Complex global model data binding with model transform method
Simple global collection data binding
Complex global collection data binding
Complex global collection data binding with controller transform method
Simple global collection data binding with model transform method
Complex global collection data binding with model transform method
Complex global collection data binding with model transform method, overridden by controller transform method
That should do it.PR with test instructions: https://github.com/appcelerator/alloy/pull/779 Did you know we had 0 tests for data binding local instances of models or collections?
We do have tests for local instance of collection, i.e https://github.com/appcelerator/alloy/blob/master/test/apps/testing/ALOY-874/ Overall, the list you have is bulletproof, and the fix looks good!
That's for a collection. Do we also have one for a instance of a model?
We now do! You just added it! :)
PR merged. Alloy@1.8.5
Verified fixed, using: MacOS 10.11.4 (15E65) Studio 4.5.0.201602170821 Ti SDK 5.2.2.v20160328141205 Appc NPM 4.2.5-1 Appc CLI 5.2.2-3 Alloy 1.8.5 Xcode 7.3 (7D175) Data binding for models is working as expected. Tested using the test app provided by Fokke as well as other created test apps. No exception is encountered and model data is correctly shown.