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

Missing methods on IE when "Disable Script Debugging" is enabled #225

Open
OzairP opened this issue Aug 23, 2019 · 2 comments
Open

Missing methods on IE when "Disable Script Debugging" is enabled #225

OzairP opened this issue Aug 23, 2019 · 2 comments

Comments

@OzairP
Copy link

OzairP commented Aug 23, 2019

On IE (tested on 11 bug same behavior reported on 8 & 9) if the "Disable Script Debugging" setting is enabled IE only provides console.error unless the console is open. This behavior is explains #29.

Attached is the execution of alert(Object.keys(console).join(', ')).
(reactStack and reactStackEnd are side effects of React but is not relevant)
IE11

This is the same execution but when the console is open.
IE11 with console
Tested on IE 11.15.16299.0 via BrowserStack

@OzairP
Copy link
Author

OzairP commented Aug 23, 2019

You can find an explanation of this behavior in this blog post, https://www.beyondjava.net/console-log-surprises-with-internet-explorer-11-and-edge.

This solution worked for me, https://stackoverflow.com/questions/7742781/why-does-javascript-only-work-after-opening-developer-tools-in-ie-once

I've simplified it to this however,

var console = window.console = window.console || {};
[
    'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
    'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
    'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
    'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
].forEach(function (method) {
    if (!console[method]) {
        console[method] = function () {};
    }
});

I will submit a PR later today fixing this issue.

@OzairP
Copy link
Author

OzairP commented Aug 29, 2019

I have held back on a PR since I am not sure if @caiogondim wants polyfills essentially bundled in the library.

CoreJS, which are the standard polyfills Babel uses, had console polyfills but they were removed for some reason. So users using this package with CoreJS will encounter this error. I've opened an issue for this zloirock/core-js#633.

Solutions

  1. Bundle console polyfill, it's small but some clients may not want it
  2. Split the console polyfill and warn developers that they need to include it if they are not using CoreJS but want to support IE (only if CoreJS will re-introduce console polyfill)

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

No branches or pull requests

1 participant