Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1738] CLI 8.1.0: crash when to listening backbone.events on required controller in ScrollableView

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-09-14T18:27:05.000+0000
Affected Version/sCLI Release 8.1.0, Alloy 1.15.1
Fix Version/sCLI Release 8.1.1
Componentsn/a
Labelsregression
ReporterTeun Klijn
AssigneeEwan Harris
Created2020-08-28T07:56:26.000+0000
Updated2021-06-16T14:13:34.000+0000

Description

When you add a backbone event listener to a required controller that's nested in a ScrollableView the app will crash. This was working with CLI 8.0.0 and still works correctly with 8.1.0 when the require isn't nested in a ScrollableView. *To reproduce* Run the example below with CLI 8.1.0. +index.js+
function doSomething(e) {
  console.log('do something!');
}

$.index.open();
+index.xml+
<Alloy>
  <Window class="container">
    <ScrollableView>
      <Require id="label" src="label" onNotify="doSomething" />
    </ScrollableView>
  </Window>
</Alloy>
+label.js+
var args = $.args;

function passClick(e) {
  $.trigger('notify');
}
+label.xml+
<Alloy>
  <Label id="label" onClick="passClick">Hello, World</Label>
</Alloy>
*Expected behavior* The app will run without crashing and the event is handled correctly. *Actual behavior* The app crashes with the following crash message:
"$.__views[\"label\"].on is not a function. (In '$.__views[\"label\"].on('notify', doSomething)', '$.__views[\"label\"].on' is undefined)";

Comments

  1. Ewan Harris 2020-08-28

    [~teunklijn@telfort.nl] thanks for the comprehensive issue, I'll move this over to the ALOY project
  2. Ewan Harris 2020-08-28

    PR: https://github.com/appcelerator/alloy/pull/967 [~teunklijn@telfort.nl], if you wanted to try and patch your CLI locally you can do the following: 1. Open up the appc CLI directory in explorer/finder * Windows: C:\Users\\.appcelerator\install\8.1.0\package\ * MacOS: ~/.appcelerator/install/8.1.0/package/ 2. Open node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Require.js 3. Apply the changes in the above PR
  3. Ewan Harris 2020-08-28

    Notes for testing, verify the test case from ALOY-1256 still works, as well as https://github.com/ewanharris/ALOY-1256-test, the test case from this ticket and maybe try the PKO/Community apps as they use the Require tag Edit: Also check out the following widgets test apps [nl.fokkezb.infiniteScroll](https://github.com/Topener/nl.fokkezb.infiniteScroll/tree/test) and [nl.fokkezb.pullToRefresh](https://github.com/Topener/nl.fokkezb.pullToRefresh/tree/test)
  4. Teun Klijn 2020-08-28

    Thanks! This does fix my issue.
  5. Lokesh Choudhary 2020-09-14

    Verified the fix with 8.1.1-master.8. Closing.

JSON Source