Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1748] Widget - Regression - weird behavior - some exporting functions are not working with CLI 8.1.1

GitHub Issuen/a
TypeBug
PriorityCritical
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels9.3.0.GA, Android, CLI8.1.1, Widget, exports, iOS
ReporterFrancisco Antonio Duran Ramirez
AssigneeAbir Mukherjee
Created2020-12-17T21:05:42.000+0000
Updated2021-06-16T15:07:46.000+0000

Description

Hello. Good afternoon. Basically adding a *widget* to any section, and trying to execute a *functionality* which it was *exported* from the section where it was added the widget; some of the exported functionalities are *not working* with the *CLI 8.1.1*, but if you try to use a lower version it is working pretty good, so that's mean that it is a regression. More details, please try to use the project attached. * XML
<Alloy>
     <Widget src="KlassWindow" id="win" />
</Alloy>
* JS
$.win.open();
$.win.showAlert();
This part about $.win.showAlert(); it is working with CLI 8.0.0, but not with CLI 8.1.1. * WIDGET XML
<Alloy>
     <Window class="container" id="win" />
</Alloy>
* WIDGET JS
var args = arguments[0] || {};

exports.open = function () {
	$.win.open();
};

exports.showAlert = function() {
	alert("CLI 8.0.0 WORKING!!!");
};
Please let me know whether you have any doubt or question. Thanks, and best, Antonio Duran.

Attachments

FileDateSize
8.0.0-Working.png2020-12-17T21:05:30.000+0000427106
8.1.1-NotWorking.png2020-12-17T21:05:30.000+0000613677
eightononenotworkingcliwidget.zip2020-12-17T20:59:50.000+00008679352

Comments

  1. John Staunton 2021-06-15

    Exact same issue here - big issues caused due to this bug, seemingly no way to work around it
  2. John Staunton 2021-06-15

    Bug also exists in CLI 9.0.1
  3. John Staunton 2021-06-16

    A workaround (posted in the TiSlack channel) that seems to work is to change your widget slightly to export the function as: $.widget.showAlert = function() { } instead of exports.showAlert... where 'widget' is the top-level View or Window of your widget
  4. Ewan Harris 2021-06-16

    This is caused by a behaviour change we overlooked when implementing the linked ticket, if a widget is the only node in a view it will become the top level node. So $.win then becomes a reference to the window in the Widget rather than the Widget itself. Another way to workaround this is to add an empty tag of some kind to the view, so that the Widget tag isn't the only tag in the view. Off the top of my head, I'm not sure how we can maintain the correct behaviour and support ALOY-1256

JSON Source