Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1317] Alloy: Default top-level ID doesn't take if-attribute into account

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-10-14T16:21:38.000+0000
Affected Version/salloy 1.7.16
Fix Version/sRelease 5.1.0, alloy 1.7.17
ComponentsXML
Labelsn/a
ReporterFokke Zandbergen
AssigneeFeon Sua Xin Miao
Created2015-10-12T08:08:02.000+0000
Updated2015-11-10T23:26:12.000+0000

Description

While ALOY-851 is said to be fixed, the following:
<Alloy>
	
	<TabGroup if="Alloy.Globals.requiredVersion">
		<Require src="list" />
		<Require src="apis" />
		<Require src="console" />
	</TabGroup>

	<Window if="!Alloy.Globals.requiredVersion">
		<Label>This sample requires Titanium 5.1 or later</Label>
	</Window>

</Alloy>
still compiles to:
    if (Alloy.Globals.requiredVersion) {
        var __alloyId11 = [];
        $.__views.__alloyId12 = Alloy.createController("list", {
            id: "__alloyId12"
        });
        __alloyId11.push($.__views.__alloyId12.getViewEx({
            recurse: true
        }));
        $.__views.__alloyId14 = Alloy.createController("apis", {
            id: "__alloyId14"
        });
        __alloyId11.push($.__views.__alloyId14.getViewEx({
            recurse: true
        }));
        $.__views.__alloyId16 = Alloy.createController("console", {
            id: "__alloyId16"
        });
        __alloyId11.push($.__views.__alloyId16.getViewEx({
            recurse: true
        }));
        $.__views.index = Ti.UI.createTabGroup({
            tabsBackgroundColor: "white",
            tabsTintColor: Alloy.CFG.brandPrimary,
            tabs: __alloyId11,
            id: "index"
        });
        $.__views.index && $.addTopLevelView($.__views.index);
    }
    if (!Alloy.Globals.requiredVersion) {
        $.__views.__alloyId17 = Ti.UI.createWindow({
            backgroundColor: "#fff",
            barColor: Alloy.CFG.brandPrimary,
            navTintColor: "#FFF",
            translucent: false,
            titleAttributes: {
                color: "#FFF"
            },
            id: "__alloyId17"
        });
        $.__views.__alloyId17 && $.addTopLevelView($.__views.__alloyId17);
        $.__views.__alloyId18 = Ti.UI.createLabel({
            text: "This sample requires Titanium 5.1 or later",
            id: "__alloyId18"
        });
        $.__views.__alloyId17.add($.__views.__alloyId18);
    }
which shows that the negative condition does not give the ID "index" to the window, which it should.

Comments

  1. Feon Sua Xin Miao 2015-10-13

    PR: https://github.com/appcelerator/alloy/pull/731
  2. Fokke Zandbergen 2015-10-14

    PR reviewed and APPROVED
  3. Feon Sua Xin Miao 2015-10-14

    PR merged.
  4. Eric Wieber 2015-11-10

    Verified fixed, using: MacOS 10.11.2 (15C31f) Studio 4.4.0.201511040454 Ti SDK 5.1.0.v20151110110428 Appc NPM 4.2.1 Appc CLI 5.1.0-45 Ti CLI 5.0.5 Alloy 1.7.24 Arrow 1.3.19 Xcode 7.2 (7C46t) Node v0.12.7 Java 1.7.0_80 production if-attributes on the top level window element do not prevent the assignment of the 'index' ID. Using the provided test (modified to not use requires), the compiled code shows that the window has an ID of 'index' and can be opened with $.index.open();.

JSON Source