mercredi 19 mars 2014

Is config really working in Ext or not?

A simple test case:

Ext.define('ClassA',{

xtype:'xa',

config:{

prop:{p:'A'}

}

});









Ext.define('ClassB',{

xtype:'xb',

extend:'ClassA',

config:{

prop:{p:'B'}

}

});





var

a = new ClassA(),

b = new ClassB();



console.log(a.prop, b.prop); // Object {p: "A"} Object {p: "A"}



console.log(a.getProp(), b.getProp()); //Object {p: "A"} objectClass {p: "B"}

console.log(a.getProp(), b.getProp()); //Object {p: "A"} objectClass {p: "B"}

console.log(a.prop, b.prop); // Object {p: "A"} objectClass {p: "B"}



a = Ext.create('ClassA',{prop:1});

b = Ext.create('ClassB',{config:{prop:2}});



console.log(a.prop, b.prop); // Object {p: "A"} Object {p: "A"}



console.log(a.getProp(), b.getProp()); //Object {p: "A"} objectClass {p: "B"}

console.log(a.getProp(), b.getProp()); // Object {p: "A"} objectClass {p: "B"}

console.log(a.prop, b.prop); // Object {p: "A"} objectClass {p: "B"}



a.setProp(3);

b.setProp(4);



console.log(a.prop, b.prop); //3 4

console.log(a.getProp(), b.getProp());// 3 4

console.log(a.getProp(), b.getProp()); // 3 4

console.log(a.prop, b.prop); // 3 4



Tried with 4.2.1



My conclusion is that config is mot working by anychance as expected and there is no elegant way to override a previously defined config property.




Aucun commentaire:

Enregistrer un commentaire