Ensure toString
and valueOf
properties are copied to a subclass only when necessary in IE6. [@382 state:resolved] (Samuel Lebeau)
This commit is contained in:
parent
ae667274f7
commit
47abfa68f0
@ -1,3 +1,5 @@
|
||||
* Ensure `toString` and `valueOf` properties are copied to a subclass only when necessary in IE6. [@382 state:resolved] (Samuel Lebeau)
|
||||
|
||||
* Make sure `getAttribute` is used without flag when accessing the "type" attribute of an iframe (IE throws error otherwise). [#118 state:resolved] (Zekid, kangax)
|
||||
|
||||
* String#gsub should escape RegExp metacharacters when the first argument is a string. [#469 state:resolved] (michael, kangax)
|
||||
|
@ -83,7 +83,16 @@ var Class = (function() {
|
||||
|
||||
if (!Object.keys({ toString: true }).length)
|
||||
properties.push("toString", "valueOf");
|
||||
|
||||
|
||||
// IE6 doesn't enumerate toString and valueOf properties,
|
||||
// Force copy if they're not coming from Object.prototype.
|
||||
if (!Object.keys({ toString: true }).length) {
|
||||
if (source.toString != Object.prototype.toString)
|
||||
properties.push("toString");
|
||||
if (source.valueOf != Object.prototype.valueOf)
|
||||
properties.push("valueOf");
|
||||
}
|
||||
|
||||
for (var i = 0, length = properties.length; i < length; i++) {
|
||||
var property = properties[i], value = source[property];
|
||||
if (ancestor && Object.isFunction(value) &&
|
||||
|
@ -112,6 +112,10 @@ new Test.Unit.Runner({
|
||||
toString: function() { return "toString" },
|
||||
valueOf: function() { return "valueOf" }
|
||||
});
|
||||
|
||||
var Bar = Class.create(Foo, {
|
||||
valueOf: function() { return "myValueOf" }
|
||||
});
|
||||
|
||||
var Parent = Class.create({
|
||||
m1: function(){ return 'm1' },
|
||||
@ -126,5 +130,7 @@ new Test.Unit.Runner({
|
||||
|
||||
this.assertEqual("toString", new Foo().toString());
|
||||
this.assertEqual("valueOf", new Foo().valueOf());
|
||||
this.assertEqual("toString", new Bar().toString());
|
||||
this.assertEqual("myValueOf", new Bar().valueOf());
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user