0

I'm developing using ionic framework, and often I see this warn:

enter image description here

Text version:

A DOM event generated from JavaScript has triggered a default action inside the browser. This behavior is non-standard and will be removed in M53, around September 2016. See https://www.chromestatus.com/features/5718803933560832 for more details.

I tried this code to avoid the above warn:

fnWarn = console.warn;
console.warn = function() {
    if (/A DOM event generated from JavaScript/i.test(arguments[0])) {
        return false;
    }
    fnWarn.apply(console, arguments);
}

But the warn still shows up.

Is there any way to hide it?

Washington Guedes
  • 4,254
  • 3
  • 30
  • 56
  • 1
    Why do you want to hide it? It's just a warning. – T.J. Crowder Sep 08 '16 at 14:36
  • @T.J.Crowder - I think he wants to avoid the warning – Jaromanda X Sep 08 '16 at 14:37
  • @JaromandaX: See the quoted code. That's not trying to address the source of the issue, it's just trying to hide it. – T.J. Crowder Sep 08 '16 at 14:39
  • @Guedes, Check out the answer in this thread - http://stackoverflow.com/questions/7042611/override-console-log-for-production – David R Sep 08 '16 at 14:39
  • @Guedes, In addition to my previous comment, I hope you will see this warnings only during your development phase, In production they won't appear – David R Sep 08 '16 at 14:39
  • @T.J.Crowder - true dat - I read the word "avoid" and didn't think to read the code :p – Jaromanda X Sep 08 '16 at 14:39
  • @DavidR: Internally-generated warnings don't necessarily go through that object. – T.J. Crowder Sep 08 '16 at 14:40
  • @DavidR: *"In production they won't appear"* They will for anyone who opens dev tools, which users of the production site can do. – T.J. Crowder Sep 08 '16 at 14:41
  • I guess he'll have to wait until Chrome 53 ... oh, wait, that's the current version of Chrome - guess they haven't figured out how to do it yet - no wait, that link takes you to a page that states this wont happen in Chrome 53 – Jaromanda X Sep 08 '16 at 14:44
  • Could be an older version Ionic. Also the solution of `var console = {}; console.log = function(){};` should include `console.warn` otherwise throws error. – user115014 Sep 08 '16 at 14:45
  • @T.J.Crowder and Jaromanda, I meant production build of "Ionic", I'm not talking about canary vs production of google chrome. – David R Sep 08 '16 at 14:46
  • @DavidR I wasn't referring to your comments at all - the issue is a warning that some behaviour in chrome is going to change ... since all other browsers behave "properly", then I can't see why, when Chrome is in line with other browsers, this will be an issue at all ... OP - what version of chrome are you running? – Jaromanda X Sep 08 '16 at 14:50
  • I've tried now: `var val = arguments[0]; debugger;` in the first line of my function. The warn showed up without stopping, I'm confuse – Washington Guedes Sep 08 '16 at 14:50
  • @DavidR: Ah, yes, this is Ionic; if end users are using it in Cordova/PhoneGap, then quite true, they won't see the message. – T.J. Crowder Sep 08 '16 at 14:50
  • @Guedes - version of chrome you are running - this shouldn't happen in chrome 53 if I'm reading that link correctly – Jaromanda X Sep 08 '16 at 14:51
  • @JaromandaX Sorry! – David R Sep 08 '16 at 14:51
  • @JaromandaX. My chrome version is 52.0.2743.116. I'm updating it right now :) – Washington Guedes Sep 08 '16 at 14:52
  • current is 53 ... update and your problem may (should) vanish – Jaromanda X Sep 08 '16 at 14:53
  • OMG!! The warn disappeared, but my selects stopped working!! How can I downgrade the chrome? – Washington Guedes Sep 08 '16 at 14:56

1 Answers1

0

David R linked to this in his comment which redefines console, so really kudos should go to him. This should help but isn't advisable to do:

var console = {};
console.log = function(){};
console.warn = function(){};
console.info = function(){};
console.error = function(){};

If using this method you should also include:

window.console = console;

to cover browsers that don't support console

It should be noted that when using bundler or similar to package your app they have the option to remove logs, warnings etc if my memory serves. If you're not packaging stuff up yourself then you could use the min version of Ionic it should exclude logs, warnings, info etc.

Also it doesn't appear to have that message in the latest version of ionic

Community
  • 1
  • 1
user115014
  • 922
  • 14
  • 23