Ted Nyberg
Ted Nyberg

Reputation: 7391

Is a console shim required when using Dojo?

I often see a shim like the following in JavaScript AMD modules to ensure console is available:

(function () {
    var f = function () { };
    if (!window.console) {
        window.console = {
            log: f, info: f, warn: f, debug: f, error: f
        };
    }
}());

Is this needed when using Dojo?

Looking through http://dojotoolkit.org/reference-guide/1.8/quickstart/debugging.html it seems Dojo is doing something similar by default?

Upvotes: 1

Views: 140

Answers (1)

Ken Franqueiro
Ken Franqueiro

Reputation: 10559

Dojo will already do this for you as long as dojo/_base/kernel is loaded. (It is a dependency of a number of common modules, e.g. lang, dom-construct, and on.)

https://github.com/dojo/dojo/blob/1.10.4/_base/kernel.js#L153-L176

Upvotes: 1

Related Questions