diff --git a/addon/safe.js b/addon/safe.js index cdd32b2b..d2de577c 100644 --- a/addon/safe.js +++ b/addon/safe.js @@ -1,10 +1,12 @@ 'use strict'; -exports.addon = function (renderer) { +exports.addon = function (renderer, options) { if (process.env.NODE_ENV !== 'production') { require('./__dev__/warnOnMissingDependencies')('safe', renderer, ['putRaw']); } + options = options || {}; + if (renderer.client) { var putRaw = renderer.putRaw; @@ -13,7 +15,11 @@ exports.addon = function (renderer) { putRaw.apply(null, arguments); // eslint-disable-next-line no-empty } catch (error) { - console.error(error); + if (process.env.NODE_ENV !== 'production') { + if (!options.quiet) { + console.error(error); + } + } } }; } diff --git a/docs/safe.md b/docs/safe.md index a8cc9b38..82d5b454 100644 --- a/docs/safe.md +++ b/docs/safe.md @@ -5,6 +5,13 @@ rule is not recognized by a brwoser (for example, it might happen if you use som that is not supported by the brwoser) it will throw. For performance reasons, `nano-css` does not catch those errors. This addon will safely catch all insertion errors and log them. +It will log errors only in development mode. If you want to suppress error messages even in +development mode set `.quiet` key on options object to true: + +```js +addonSave(nano, {quiet: true}); +``` + ## Installation