[ALOY-938] Using conditional TSS results in unexpected _.extend() calls
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-11-26T21:59:42.000+0000 |
Affected Version/s | Alloy 1.3.0 |
Fix Version/s | Alloy 1.4.0, 2014 Sprint 07 |
Components | Styling |
Labels | alloy, compiler, conditions, qe-manualtest |
Reporter | Fokke Zandbergen |
Assignee | Tim Poulsen |
Created | 2014-01-24T15:35:27.000+0000 |
Updated | 2014-11-26T21:59:42.000+0000 |
Description
I have a complex project where the I saw a lot of inefficient and unlogical
_.extend()
calls in the controller.
I brought it down to this test case:
1. Create a default Alloy project.
2. Create a styles/app.tss
.
3. In both styles/index.tss
and styles/app.tss
use:
"Window[formFactor=handheld]": {
title: "Window handheld"
}
4. Compile the project and see similar code like the following:
$.__views.id = Ti.UI.createWindow(function() {
var o = {};
_.extend(o, {});
Alloy.isHandheld && _.extend(o, {
title: "Window handheld"
});
_.extend(o, {});
Alloy.isHandheld && _.extend(o, {
title: "Window handheld"
});
_.extend(o, {
id: "id"
});
return o;
}());
The empty _.extend(o, {});
and the identical isHandheld
lines should not be there.
PR https://github.com/appcelerator/alloy/pull/357 Functional test: Follow the steps described in ticket description. There should be no extra extend(o, {}) statements now.
Tested as above described, there is no empty _.extend(o, {}); and identical isHandheld in the controller after building the app. Verified the fix on: Device : iPhone 5s , iOS version : 7.1 SDK: 3.3.0.v20140512162513 CLI version : 3.3.0-dev OS : MAC OSX 10.9.2 Alloy: 1.4.0-dev ACS: 1.0.14 npm:1.3.2 LiveView: 1.0.4 Appcelerator Studio, build: 3.3.0.201405121247 titanium-code-processor: 1.1.1 XCode : 5.1.1