jayphelps / core-decorators

Library of stage-0 JavaScript decorators (aka ES2016/ES7 decorators but not accurate) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic.
MIT License
4.52k stars 263 forks source link

fix profiling in IE #111

Closed artptr closed 7 years ago

artptr commented 7 years ago

Current implementation causes an error in IE11 because console.profile there isn't a "normal" function with Function prototype.

jayphelps commented 7 years ago

Hey! Thanks for the PR. Can you clarify what you mean? What is the exact error produced?

artptr commented 7 years ago

It's easy to see from the following examples from the IE's developer console: console.log

function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { ...

console.log.__proto__

function() { [native code] }

console.profile

[object] { }

console.profile.__proto__

undefined

console.profile.bind(console)

Object doesn't support property or method 'bind'

console.profile.toString()

"
function profile() {
    [native code]
}
"

The console.profile function is really present in IE, but it seems that it is a special deep engine-implemented function without JS's function prototype. So there isn't .bind property and its calling in the initialization stage causes an error.

artptr commented 7 years ago

BTW, it seems that you already fixed that issue by 74615e2.

jayphelps commented 7 years ago

Oh thanks! now I understand, it doesn't have .bind. Should be fixed by 0.18.0 as you mentioned 😄 Thanks for letting me know!