Titanium JIRA Archive
Alloy (ALOY)

[ALOY-938] Using conditional TSS results in unexpected _.extend() calls

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-11-26T21:59:42.000+0000
Affected Version/sAlloy 1.3.0
Fix Version/sAlloy 1.4.0, 2014 Sprint 07
ComponentsStyling
Labelsalloy, compiler, conditions, qe-manualtest
ReporterFokke Zandbergen
AssigneeTim Poulsen
Created2014-01-24T15:35:27.000+0000
Updated2014-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.

Comments

  1. Tim Poulsen 2014-04-03

    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.
  2. Paras Mishra 2014-05-13

    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

JSON Source