Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1323] Alloy: module-tag in Alloy element effects all controller-views

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-11-20T17:35:47.000+0000
Affected Version/salloy 1.7.16, alloy 1.7.26
Fix Version/sRelease 5.2.0, alloy 1.7.27
ComponentsXML
Labelsn/a
ReporterFokke Zandbergen
AssigneeFeon Sua Xin Miao
Created2015-11-01T18:49:35.000+0000
Updated2016-02-02T21:23:00.000+0000

Description

The attached app-folder demonstrates that when you use the module tag on the <Alloy> tag of one view, this will be applied to *all* other controller-views as well. 1. Compile the app. 2. Open Resources/iphone/controllers/testWindow.js. 3. Confirm that it has (require("testModule").createWindow || Ti.UI.createWindow) for all views as well, while only app/views/index.xml has has the module tag. Found by [~falko]

Attachments

FileDateSize
app.zip2015-11-01T18:49:55.000+00003723

Comments

  1. Feon Sua Xin Miao 2015-11-03

    According to ALOY-1018, this doesn't seem like a bug.
  2. Andrey Tkachenko 2015-11-03

    what do you say to that? */app/lib/testModule.js*
       exports.createLabel = function(opts) {
       	return Ti.UI.createLabel(_.extend(opts, {
       		text: "Click me!"
       	}));
       };
       
    *app/controllers/index.js*
       function doClick(e) {
           Alloy.createController('testWindow').getView().open();
       }
       $.index.open();
       
    *app/views/index.xml*
       <Alloy module="testModule">
       	<Window class="container">
       		<Label id="label" onClick="doClick" />
       	</Window>
       </Alloy>
       
    *app/views/testWindow.xml*
       <Alloy>
       	<Window layout="vertical">
       		<Label>Do you see this text?</Label>
       		<Label>And this!</Label>
       	</Window>
       </Alloy>
       
  3. Andrey Tkachenko 2015-11-03

    I think it is bad idea to propogate Alloy tag attribute specified in one View to the all other Views. It can be lead to bugs that very hard to find.
  4. Feon Sua Xin Miao 2015-11-03

    [~falko], would this work for you?
       <Alloy>
       	<Window class="container" module="testModule">
       		<Label id="label" onClick="doClick" />
       	</Window>
       </Alloy>
       
  5. Andrey Tkachenko 2015-11-04

    Each View must relate to only his controller implementation and not has influence to other.
  6. Fokke Zandbergen 2015-11-04

    [~fmiao] this *is* a bug. ALOY-1018 does not request for the module tag on an Alloy element to effect all views in the app, only the current.
  7. Andrey Tkachenko 2015-11-04

    I can build controller with many views at root under Alloy tag and in this case I can use module attribute in Alloy tag but it not must has influence to other controllers.
  8. Brenton House 2015-11-11

    This seems to be broken from version 1.7.8 to the current version 1.7.24
  9. Brenton House 2015-11-11

    I am not opposed to this being a feature that is available to developers but I think it should probably go somewhere more global.
  10. Andrey Tkachenko 2015-11-12

    It must work like autoStyle:
         To enable autostyle, set the autoStyle attribute to true either in the XML markup or the config.json file. You can enable autostyle for a individual component, for all components in a controller, or for all controllers in a project.
        
        * To enable autostyle for an individual component, set the autoStyle attribute to true on the XML tag (for example, <View autoStyle="true">).
        * To enable autostyle for components in a controller, set the autoStyle attribute to true on the root <Alloy/> tag (for example, <Alloy autoStyle="true">).
        * To enable autostyle for all controllers in an Alloy project, set the autoStyle field to true in the config.json file, for example:
        
        
  11. Feon Sua Xin Miao 2015-11-12

    [~brentonhouse], what exactly is broken from 1.7.8? Did the module property work differently in earlier versions?
  12. Feon Sua Xin Miao 2015-11-19

    PR: https://github.com/appcelerator/alloy/pull/742 To Test: 1. Test for ALOY-1018 should pass. 2. Run attached app, Resources/iphone/controllers/testWindow.js shouldn't have (require("testModule").createWindow || Ti.UI.createWindow) for all views.
  13. Andrey Tkachenko 2015-11-20

    I confirm.
    (require("testModule").create... || Ti.UI.create...)
    only present in controller which contains module attribute in his alloy tag. Tested on your branch ALOY-1323
  14. Feon Sua Xin Miao 2015-11-20

    Thank you [~falko]!
  15. Feon Sua Xin Miao 2015-11-20

    PR merged.
  16. Brenton House 2015-11-23

    Is there now a global way of doing this such as in the config.json file?
  17. Fokke Zandbergen 2015-11-23

    No, we now fixed the bug this ticket was about. You can do a new ticket for a feature request for this.
  18. Eric Wieber 2016-02-02

    Verified fixed, using: MacOS 10.11.3 (15D21) Studio 4.5.0.201601262138 Ti SDK 5.2.0.v20160202103508 Appc NPM 4.2.3-1 Appc CLI 5.2.0-239 Alloy 1.7.33 Xcode 7.2 (7C68) Using the module property on the tag no longer applies to the sub views. Tested using the provided sample app contents and the code in ALOY-1018.

JSON Source