PDA

View Full Version : Ext.apply + IE.toString + IE.valueOf



Gabor Turi
30 Jan 2011, 11:12 PM
Hi!
Why is the toString condition in Ext.override function? Why not in Ext.apply?
And valueOf?



Ext.apply = function (o, c, defaults) {
if (defaults) {
Ext.apply(o, defaults);
}
if (o && typeof c === 'object') {
for (var p in c) {
o[p] = c[p];
}
if (Ext.isIE) {
if (c.hasOwnProperty('toString')) {
o.toString = c.toString;
}
if (c.hasOwnProperty('valueOf')) {
o.valueOf = c.valueOf;
}
}
}
return o;
};

Ext.override = function (origclass, overrides) {
if (overrides) {
Ext.apply(origclass.prototype, overrides);
}
};
The valueOf is bad too!



var obj = {
foo: function () {},
toString: function () {},
valueOf: function () {}
};
for (var attr in obj) {
alert(attr);
}
Sorry for my poor English!