Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1602] Avoid some global variables to be only available in parent controller.

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-02-07T00:23:12.000+0000
Affected Version/sn/a
Fix Version/sCLI Release 7.0.3
ComponentsTooling
Labelsn/a
ReporterHans Knöchel
AssigneeBruce Wayne
Created2018-02-01T15:36:12.000+0000
Updated2018-04-11T21:30:54.000+0000

Description

Quote from [Github](https://github.com/appcelerator/alloy/pull/859): {quote} I don't understand why it is necessary to remove "$model", "__parentSymbol" or "__itemTemplate" from the "arguments" variable. This is causing issues when passing "$model" for example to a controller which is inheriting from another controller as per Alloy Controller Inheritance documentation (http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Controllers-section-src-34636384_AlloyControllers-Inheritance). If we delete it from there, only the parent will have "$model" properly set but the child controller won't as it's deleted from "arguments". Another option would be to run "__processArg()" before calling the parent controller but this would mean only the child controller has $model properly set, it will be null for the parent one. In order to reproduce:

index.js

Alloy.createController('child', \{ $model: aBackboneModelObject \});

parent.js

console.log(_.isNull($model)); // always return false ...

child.js

exports.baseController = "parent"; console.log(_.isNull($model)); // always return true {quote}

Comments

  1. Ewan Harris 2018-02-07

    Is ALOY-897 no longer a problem? Checking git blame seems to show that's why this was done, I'm not well versed in widgets enough to know whether this is a known thing developers handle or not, the few widgets I checked on gitt.io seem to handle removing some of the properties
  2. Lokesh Choudhary 2018-04-11

    Verified the fix in alloy 1.12.0 in core 7.0.3-master.36. Closing.

JSON Source