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

console.log.apply not supported on IE11? #2227

Closed
fantanamihai opened this Issue Feb 2, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@fantanamihai
Contributor

fantanamihai commented Feb 2, 2016

Hi guys!
When using I'm getting a wired 'Object doesn't support this action' error in can/util/can.js, _logger function
For me, the fix was to replace the if-else with a try-catch.

@rjgotten

This comment has been minimized.

Show comment
Hide comment
@rjgotten

rjgotten Feb 3, 2016

@meconcomputer

In IE console is a host object and its methods are not true JS functions that descend from Function.
Therefore console.log has neither a call nor an apply method and even attempting to access them leads to a runtime error.

You can get a cross-browser compatible implementation via a little trick where you 'apply call', e.g. ,

_logger : function( type, arr ) {
  if (( "console" in window ) && ( type in console )) {
    var call = Function.prototype.call;
    call.apply( call, [ console[ type ], console ].concat( arr ));
  }
}

rjgotten commented Feb 3, 2016

@meconcomputer

In IE console is a host object and its methods are not true JS functions that descend from Function.
Therefore console.log has neither a call nor an apply method and even attempting to access them leads to a runtime error.

You can get a cross-browser compatible implementation via a little trick where you 'apply call', e.g. ,

_logger : function( type, arr ) {
  if (( "console" in window ) && ( type in console )) {
    var call = Function.prototype.call;
    call.apply( call, [ console[ type ], console ].concat( arr ));
  }
}
@fantanamihai

This comment has been minimized.

Show comment
Hide comment
@fantanamihai

fantanamihai Feb 4, 2016

Contributor

Agree. But doesn't this mean that _logger should be "officially" patched on master also?

Contributor

fantanamihai commented Feb 4, 2016

Agree. But doesn't this mean that _logger should be "officially" patched on master also?

@rjgotten

This comment has been minimized.

Show comment
Hide comment
@rjgotten

rjgotten commented Feb 4, 2016

It does.

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