envjs / env-js

A pure-JavaScript browser environment.
http://www.envjs.com/
87 stars 19 forks source link

Log statement causing trouble #13

Open orslumen opened 13 years ago

orslumen commented 13 years ago

The method insertBefore in dom.js starts with the following debug statement:

log.debug('insert %s Before %s', newChild.nodeName, refChild.nodeName);

But results in a TypeError: Cannot read property 'nodeName' of null when the refChild (or newChild is undefined). This can be fixed as follows:

log.debug('insert %s Before %s', newChild && newChild.nodeName, refChild && refChild.nodeName);

See commit https://github.com/orslumen/env-js/commit/c22faaf7c3ec3b290b8e18a8b3afd537bffb5982

But would it not be better (performance wise) to comment out all log statements, or to add something like if (Log.level <= debug) { log.debug(...) } to all debug statements?