[AC-6452] Alloy custom $model.__transform mapping is broken
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Alloy |
Labels | n/a |
Reporter | Jorge Macias Garcia |
Assignee | Shak Hossain |
Created | 2019-12-03T08:19:15.000+0000 |
Updated | 2019-12-03T22:24:03.000+0000 |
Description
EDIT: Updated with working error example:
This [commit](https://github.com/appcelerator/alloy/commit/0d6a312cfa42d82919b695f38583a31cbedeb9c2#diff-a59a2178e486f81366775c39e5393695) brokes this use case:
- Custom mapping object with *$model.__transform* property
Example:
It's my fault Ewan. Try passing a deep object:
{noformat}
[ERROR] Script Error {
[ERROR] column = 385;
[ERROR] line = 49;
[ERROR] message = "undefined is not an object (evaluating 'Alloy['Models']['user'].on')";
[ERROR] sourceURL = "file:///Users/jormagar/Library/Developer/CoreSimulator/Devices/E90BCD03-DD1A-4ED4-A53E-E855EAF8D0F7/data/Containers/Bundle/Application/1285D017-A679-4740-AF70-0C257BD62EAF/AlloyDeepBinding.app/alloy/controllers/detail.js";
[ERROR] stack = " at Controller(/alloy/controllers/detail.js:49:385)\n at (/alloy.js:428:53)\n at doClick(/alloy/controllers/index.js:54:27)";
[ERROR] toJSON = "";
[ERROR] }
{noformat}
//detail.xml
<Alloy>
<Window layout="vertical">
<Label text="{user.owner.name}" top="50"/>
<Label text="{user.contributor.name}" top="75"/>
</Window>
</Alloy>
//index.js
function onClick() {
Alloy.createController('MyView', {
$model: {
__transform: {
user: {
owner: {
name: 'Bob'
},
contributor: {
name: 'Tom'
}
}
}
}
}).getView().open();
}
$.index.open();
Coming back to the previous code before commit fixes it.
[~jormagar] could you elaborate a little more as to what the expected outcome is here, my code is below. When using the latest version of alloy (1.14.5) and building to an iOS simulator, I'm seeing two labels with "Bob" and "Bobson" after clicking on the button, when I revert the referenced commit I see exactly the same. To me the behaviour I'm seeing is expected, am I wrong? Am I creating the test case incorrectly? When
It's my fault Ewan. Try passing a deep object: {noformat} [ERROR] Script Error { [ERROR] column = 385; [ERROR] line = 49; [ERROR] message = "undefined is not an object (evaluating 'Alloy['Models']['user'].on')"; [ERROR] sourceURL = "file:///Users/jormagar/Library/Developer/CoreSimulator/Devices/E90BCD03-DD1A-4ED4-A53E-E855EAF8D0F7/data/Containers/Bundle/Application/1285D017-A679-4740-AF70-0C257BD62EAF/AlloyDeepBinding.app/alloy/controllers/detail.js"; [ERROR] stack = " at Controller(/alloy/controllers/detail.js:49:385)\n at (/alloy.js:428:53)\n at doClick(/alloy/controllers/index.js:54:27)"; [ERROR] toJSON = "