Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2245] Custom properties not passed by reference

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-04-02T23:51:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterTristan Marly
AssigneeMauro Parra-Miranda
Created2012-12-13T07:53:36.000+0000
Updated2016-03-08T07:41:14.000+0000

Description

I don't know if this is a bug or a weird behavior, but it seems that when creating some Ti.UI objects, custom properties are cloned and not passed by reference. Here is a simple test case illustrating the pb:
var win = Ti.UI.createWindow({
        layout: 'vertical',
});

var customPropertyValue = {text: "hello"};

// Build a table
var data = [
	Ti.UI.createTableViewRow({
		title: 'Row 1',
		customProperty: customPropertyValue,
	}),
];
var table = Ti.UI.createTableView({
		data: data,
});

// Click events
table.addEventListener('click', function(e) {
	Ti.API.info('Event ! text=' + e.rowData.customProperty.text);
});
win.add(table);
win.open();

// Modify the property
customPropertyValue.text = "bye";
As you can see, the customPropertyValue is modified at the end of the code. But when we later click on the row, the displayed message is "hello", and not "bye". So at the step "build a table", it seems that the customPropertyValue is cloned.

Comments

  1. Pedro Enrique 2013-04-02

    For native components the properties are passed by value
  2. Mauro Parra-Miranda 2013-11-24

    Invalid issue.

JSON Source