VinylFox
1 Jan 2010, 9:57 AM
I need some feedback from the team about making this change / if it should be made.
Ext version tested:
Ext 3.1 rev 5766
Adapter used:
ext
Description:
If too many levels are specified for the ref config, it will find undefined. This is a change in logic from previous versions, not necessarily a bug. In fact, from a technical standpoint it works more accurately now than it did before...however its still different from previous versions.
Test Case:
Run this code on any of the example pages. Since rev 5766 this code will fail. Previous versions will work.
new Ext.Window({
title: 'Test',
id: 'test',
width: 200,
height: 100,
html: 'Bwah bwah',
bbar: [{
text: 'Boo',
ref: '../../../../../buttonBoo',
handler: function(){
Ext.getCmp('test').buttonBoo.setText('New Boo');
Ext.getCmp('test').buttonBleh.setText('New Bleh').disable();
}
}, {
text: 'Bleh',
ref: '../../../../../buttonBleh'
}]
}).show();
This is because an if statement was removed in the loop that checks owners, allowing undefined to be set as the last item found in the owner chain.
Fix:
Ext.override(Ext.Component, {
initRef : function() {
if(this.ref && !this.refOwner){
var levels = this.ref.split('/'),
last = levels.length,
i = 0,
t = this;
while(t && i < last){
if (t.ownerCt) {
t = t.ownerCt;
}
++i;
}
if(t){
t[this.refName = levels[--i]] = this;
this.refOwner = t;
}
}
}
});
This fix promotes sloppy code, allowing users to specify more levels than exist in a ref, however this is how it has worked previously.
Ext version tested:
Ext 3.1 rev 5766
Adapter used:
ext
Description:
If too many levels are specified for the ref config, it will find undefined. This is a change in logic from previous versions, not necessarily a bug. In fact, from a technical standpoint it works more accurately now than it did before...however its still different from previous versions.
Test Case:
Run this code on any of the example pages. Since rev 5766 this code will fail. Previous versions will work.
new Ext.Window({
title: 'Test',
id: 'test',
width: 200,
height: 100,
html: 'Bwah bwah',
bbar: [{
text: 'Boo',
ref: '../../../../../buttonBoo',
handler: function(){
Ext.getCmp('test').buttonBoo.setText('New Boo');
Ext.getCmp('test').buttonBleh.setText('New Bleh').disable();
}
}, {
text: 'Bleh',
ref: '../../../../../buttonBleh'
}]
}).show();
This is because an if statement was removed in the loop that checks owners, allowing undefined to be set as the last item found in the owner chain.
Fix:
Ext.override(Ext.Component, {
initRef : function() {
if(this.ref && !this.refOwner){
var levels = this.ref.split('/'),
last = levels.length,
i = 0,
t = this;
while(t && i < last){
if (t.ownerCt) {
t = t.ownerCt;
}
++i;
}
if(t){
t[this.refName = levels[--i]] = this;
this.refOwner = t;
}
}
}
});
This fix promotes sloppy code, allowing users to specify more levels than exist in a ref, however this is how it has worked previously.