Skip to content

Commit 712ddd2

Browse files
authored
Merge pull request #30 from darrinmn9/feat/add-allow-console-clear-option
feat: add option 'allowConsoleClears'
2 parents f115d56 + 51d246c commit 712ddd2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docs/guide/options.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,27 @@ Vue.use(VueAxe, {
1919
To check manually, use [$axe.run](/guide/api.html#run)
2020
:::
2121

22+
## allowConsoleClears
23+
24+
| Type | Default |
25+
| -------- | -------- |
26+
| Boolean | `true` |
27+
28+
If false, disables all console clears (overriding `clearConsoleOnUpdate`).
29+
30+
```js
31+
Vue.use(VueAxe, {
32+
allowConsoleClears: false // disable all console clears
33+
})
34+
```
35+
2236
## clearConsoleOnUpdate
2337

2438
| Type | Default |
2539
| -------- | -------- |
2640
| Boolean | `false` |
2741

28-
If true, clean the console each time the component is updated.
42+
If true, clean the console each time the component is updated. No effect if `allowConsoleClears = false`.
2943

3044
```js
3145
Vue.use(VueAxe, {

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const draf = (cb) => requestAnimationFrame(() => requestAnimationFrame(cb
44

55
export const defaultOptions = {
66
auto: true,
7+
allowConsoleClears: true,
78
clearConsoleOnUpdate: false,
89
delay: 500,
910
config: {
@@ -31,7 +32,9 @@ export const defaultOptions = {
3132
export function clear (forceClear = false, options) {
3233
resetCache()
3334
if (forceClear || options.clearConsoleOnUpdate) {
34-
console.clear()
3535
resetLastNotification()
36+
if (options.allowConsoleClears) {
37+
console.clear()
38+
}
3639
}
3740
}

0 commit comments

Comments
 (0)