[ALOY-1323] Alloy: module-tag in Alloy element effects all controller-views
| GitHub Issue | n/a |
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-11-20T17:35:47.000+0000 |
| Affected Version/s | alloy 1.7.16, alloy 1.7.26 |
| Fix Version/s | Release 5.2.0, alloy 1.7.27 |
| Components | XML |
| Labels | n/a |
| Reporter | Fokke Zandbergen |
| Assignee | Feon Sua Xin Miao |
| Created | 2015-11-01T18:49:35.000+0000 |
| Updated | 2016-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
| File | Date | Size |
| app.zip | 2015-11-01T18:49:55.000+0000 | 3723 |
According to ALOY-1018, this doesn't seem like a bug.
what do you say to that? */app/lib/testModule.js*
*app/controllers/index.js*exports.createLabel = function(opts) { return Ti.UI.createLabel(_.extend(opts, { text: "Click me!" })); };*app/views/index.xml*function doClick(e) { Alloy.createController('testWindow').getView().open(); } $.index.open();*app/views/testWindow.xml*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.
[~falko], would this work for you?
Each View must relate to only his controller implementation and not has influence to other.
[~fmiao] this *is* a bug. ALOY-1018 does not request for the
moduletag on anAlloyelement to effect all views in the app, only the current.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.
This seems to be broken from version 1.7.8 to the current version 1.7.24
I am not opposed to this being a feature that is available to developers but I think it should probably go somewhere more global.
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:[~brentonhouse], what exactly is broken from 1.7.8? Did the module property work differently in earlier versions?
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.jsshouldn't have(require("testModule").createWindow || Ti.UI.createWindow)for all views.I confirm.
only present in controller which contains(require("testModule").create... || Ti.UI.create...)moduleattribute in hisalloytag. Tested on your branch ALOY-1323Thank you [~falko]!
PR merged.
Is there now a global way of doing this such as in the config.json file?
No, we now fixed the bug this ticket was about. You can do a new ticket for a feature request for this.
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