Skip to content

feat: add option 'allowConsoleClears' #30

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

Merged
merged 3 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@ Vue.use(VueAxe, {
To check manually, use [$axe.run](/guide/api.html#run)
:::

## allowConsoleClears

| Type | Default |
| -------- | -------- |
| Boolean | `true` |

If false, disables all console clears (overriding `clearConsoleOnUpdate`).

```js
Vue.use(VueAxe, {
allowConsoleClears: false // disable all console clears
})
```

## clearConsoleOnUpdate

| Type | Default |
| -------- | -------- |
| Boolean | `false` |

If true, clean the console each time the component is updated.
If true, clean the console each time the component is updated. No effect if `allowConsoleClears = false`.

```js
Vue.use(VueAxe, {
Expand Down
5 changes: 4 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const draf = (cb) => requestAnimationFrame(() => requestAnimationFrame(cb

export const defaultOptions = {
auto: true,
allowConsoleClears: true,
clearConsoleOnUpdate: false,
delay: 500,
config: {
Expand Down Expand Up @@ -31,7 +32,9 @@ export const defaultOptions = {
export function clear (forceClear = false, options) {
resetCache()
if (forceClear || options.clearConsoleOnUpdate) {
console.clear()
resetLastNotification()
if (options.allowConsoleClears) {
console.clear()
}
Comment on lines 35 to +38
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure exactly what resetLastNotification does. Not sure if it makes more sense for it to be inside the if (options.allowConsoleClears) block or not?

}
}