Skip to content

Commit

Permalink
feat: 🎸 make safe addom less chatty
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 14, 2018
1 parent 7142d86 commit c449a13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions addon/safe.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
}
}
}
};
}
Expand Down
7 changes: 7 additions & 0 deletions docs/safe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

1 comment on commit c449a13

@streamich
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build version: 2.1.0-feat-various.60 🤞 feat-various on CircleCI 🎉

Please sign in to comment.