REQUIRED INFORMATION


Ext version tested:
  • Ext 4.1.1

Browser versions tested against:
  • Any

DOCTYPE tested against:
  • n/a

Description:
  • I ran into an issue that took quite some time to debug in our application. I have isolated it to the fact that when one creates 2 instances of a class the state of the first instance is lost and replaced by the state of the second one. This is happening when the class is defined by passing a function instead of an object as the second parameter to Ext.define as documented in extjs-4.1.1/docs/index.html#!/api/Ext-method-define

    I have reproduced it with the simple class below

Steps to reproduce the problem:
  • try code below
  • you will see that when the second instance is created the name property in the first instance takes the value of the one in the second instance

The result that was expected:
  • each instance to have its own state

Test Case:

Code:
Ext.define('test.class.PrivateExample',function(){
 var itsName = 'defaultName';  // this is private

function constructor(a) { if ( a !== undefined && a.name !== undefined ) {itsName = a.name;}}

function privateFct1() {return itsName;}

// The public API to this class
return  { publicFunction1: privateFct1, constructor: constructor	}
});


function testPrivateExample() {
var testObject = Ext.create('test.class.PrivateExample',{name: 'test1'});
console.log ( "First Object: name: " + testObject.publicFunction1() );
var testObject2 = Ext.create('test.class.PrivateExample',{name: 'test2'});
console.log ( "Second Instance: name: " + testObject2.publicFunction1() );
console.log ("  Now you see that first instance name is incorrect ! ");
console.log ( "First Instance: name: " + testObject.publicFunction1() );
}


HELPFUL INFORMATION


Screenshot or Video:
  • attached

See this URL for live test case: http://


Debugging already done:
  • none

Possible fix:
  • not provided

Additional CSS used:
  • only default ext-all.css
  • custom css (include details)

Operating System:
  • ________
  • any