waneck / testrepo

0 stars 0 forks source link

Issue 1850 - IE < 9 toString() override fail - haxe #1850

Closed waneck closed 11 years ago

waneck commented 11 years ago

[Google Issue #1850 : http://code.google.com/haxe/issues/detail?id=1850] by Yar3333@gmail.com, at 2013-05-24T11:25:56.000Z Haxe 2.10

Code

class A { public function toString() return "A" }

class B { override function toString() return "B" }

class Main { static function main() { // give "A" for IE8 and "B" for FF, Chrome and IE9 js.Lib.alert(new B().toString()); } }

The problem

while object properties iteration does not return "toString" (is a magick method for IE<9).

Solution

change: function $extend(from, fields) { function inherit() {}; inherit.prototype = from; var proto = new inherit(); for (var name in fields) proto[name] = fields[name]; return proto; }

to: function $extend(from, fields) { function inherit() {}; inherit.prototype = from; var proto = new inherit(); for (var name in fields) proto[name] = fields[name]; if (fields.toString !== Object.prototype.toString) proto.toString = fields.toString; return proto; }

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2013-05-24T11:54:10.000Z] This issue was closed by revision r6693.