PDA

View Full Version : [4.0.2 CORE] Ext,ClassManager : setNamespace can't be call twice



wzl002
13 Jun 2011, 11:10 PM
Ext.ClassManager setNamespace: function(name, value) is a function which will be call when use Ext.define().

If use the function with a same name twice, then in the function, " leaf = parts.pop()" will make the namespace be cut in the seconde time call.

For example:

Ext.define('a.b.c', {});
console.log(a.b.c)
Ext.define('a.b.c', {});
console.log(a.b.c)
Ext.define('a.b.c', {});
console.log(a.b.c)
Ext.define('a.b.c', {});
console.log(a.b.c)

the result will be

Object
undefined
error: a.b is undefined
error: a is undefined



I had report this before and I really hope this could be correct so that I do not need to correct the code every new release. ^_^

This is what I made update in source code. And it's all right so far.

setNamespace: function(name, value) {
var root = Ext.global,
parts = this.parseNamespace(name),
// leaf = parts.pop(), // update ///////////////////////////
leaf = parts[parts.length - 1],
i, ln, part;

//for (i = 0, ln = parts.length; i < ln; i++) { // update ///////////////
for (i = 0, ln = parts.length - 1; i < ln; i++) {

...

wzl002
16 Jun 2011, 6:23 PM
ignore again? Or it's my fault and I made some mistake?