HaxeFoundation/haxe — pull request #2441 by Blank101 (2013-12-08 20:45:33+00:00)
Title: [JS] Fixed instanceof for native functions

As part of the ES5 spec (http://ecma262-5.com/ELS5_HTML.htm#Section_11.4.3), native functions return "object" when typeof is called on them. Chrome, Firefox, Opera implement the spec incorrectly and return "function" so there are no problems, but at least iOS Safari (possibly desktop Safari) implement the spec correctly and return "object". This leads to cast throwing errors if you are working with native DOM objects.

For example the following code works on most browsers, but not iOS Safari:

js.Browser.document.createDivElement();

This is because the createDivElement() method attempts to cast js.html.Element to js.html.DivElement, but both are native functions and will fail the js.Boot.__instanceof() test.