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;
}
[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; }