aflx
13 Nov 2011, 2:21 AM
REQUIRED INFORMATION
Ext version tested:
Sencha Touch 2 PR2
Browser versions tested against:
Chrome 15 (Mac OSX Lion)
Description:
When creating new instances of the same class, it seems like some class-members acts like static variables.
Steps to reproduce the problem:
create 2 instances of a class with an array-member
get the member of instance1 and push something
same for the second instance
The result that was expected:
two different arrays with different content
The result that occurs instead:
only one array with the same content
Test Case:
Test class
Ext.define("Test", {
config: {
array: []
},
init: function() {
}
});
Test:
var test1 = Ext.create("Test");
test1.getArray().push("bla");
var arr = test1.getArray();
var test2 = Ext.create("Test");
test2.getArray().push("blub");
var arr2 = test2.getArray(); // expected: length == 1, content == "blub"; result: length == 2, content: "bla", "bub"
HELPFUL INFORMATION
Debugging already done:
none
Possible fix:
set the array in the constructor
constructor: function(config) {
this.initConfig(config);
this.callParent([config]);
this.setArray([]);
return this;
}
Operating System:
Mac OSX Lion
Ext version tested:
Sencha Touch 2 PR2
Browser versions tested against:
Chrome 15 (Mac OSX Lion)
Description:
When creating new instances of the same class, it seems like some class-members acts like static variables.
Steps to reproduce the problem:
create 2 instances of a class with an array-member
get the member of instance1 and push something
same for the second instance
The result that was expected:
two different arrays with different content
The result that occurs instead:
only one array with the same content
Test Case:
Test class
Ext.define("Test", {
config: {
array: []
},
init: function() {
}
});
Test:
var test1 = Ext.create("Test");
test1.getArray().push("bla");
var arr = test1.getArray();
var test2 = Ext.create("Test");
test2.getArray().push("blub");
var arr2 = test2.getArray(); // expected: length == 1, content == "blub"; result: length == 2, content: "bla", "bub"
HELPFUL INFORMATION
Debugging already done:
none
Possible fix:
set the array in the constructor
constructor: function(config) {
this.initConfig(config);
this.callParent([config]);
this.setArray([]);
return this;
}
Operating System:
Mac OSX Lion