Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No polyfill for IE Console API #633

Open
OzairP opened this issue Aug 29, 2019 · 3 comments
Open

No polyfill for IE Console API #633

OzairP opened this issue Aug 29, 2019 · 3 comments

Comments

@OzairP
Copy link

OzairP commented Aug 29, 2019

When "Disable Script Debugging" is enabled on IE11 and the console is closed, IE11 will only provide console.error whilst other methods which are declared Non-Nullable in WHATWG Console Specification IDL do not exist. In IE8 & 9 the Console API is not defined given the same conditions.
I have personally reproduced this on IE11, but not IE8&9 behavior due to lack of IE8&9 but this behavior has been reported many times [1] [2] [3]

This introduces a major inconsistency with the WHATWG Spec since developers expect the Console API to be provided and depend on logging even in production. Even worse the bug disappears when the console is opened so it may be hard to trace.

This leads to developer-consumers having to add their own polyfill which defeats the purpose of CoreJS having standard polyfills.

CoreJS correctly supported this polyfill via core.log but it was removed in CoreJS 2.0.0 via 28ceca3 (changelog).

I cannot find any information as to why core.log was removed but I believe it should be re-introduced for IE targets.

@zloirock
Copy link
Owner

This module was removed since binding methods to the console object broke a stack trace. For example, console.log should indicate the line where it was shown, console.error also a stack trace of the error, but with this polyfill you will see the line where it's defined in core-js. See #14. I don't remember why it was completely removed, even with caps for cases when it was missed completely.

@OzairP
Copy link
Author

OzairP commented Aug 29, 2019

I saw that issue but did not put two and two together, that makes sense now. I see the old implementation creates it's own console object. Monkey patching the existing console object for non-existent methods will resolve this issue. Browsers with compliant Console API will use the native function. IE where log/etc is disabled has a no op function. When the debugger is opened the console methods will be re-assigned to native functions. I believe something like this will work?

I can PR this and test it if you think it'll work.

var $ = require('../internals/export');

$({ static: true, target: 'console'}, {
    log: function(){},
    // ...
});

@zloirock
Copy link
Owner

After #14 it was splitted to 2 modules, with binding methods and just a cap. A cap was removed from 0.6 - "creates too many problems". Need to remember why. I'll think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants