From c5483ef269d262f65a69eb4c3f862202ff295137 Mon Sep 17 00:00:00 2001 From: Jairo Valderrama Date: Fri, 8 Jul 2022 12:20:41 -0500 Subject: [PATCH 1/3] fix: allows to set a default element to run on the first load This element will be used as the default context sent to `axe.run` Fix: #36 --- src/audit.js | 2 +- src/index.js | 2 +- src/utils.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/audit.js b/src/audit.js index 8606913..367db3c 100644 --- a/src/audit.js +++ b/src/audit.js @@ -11,7 +11,7 @@ export function checkAndReport (options, node, label) { const deferred = createDeferred() style = { ...options.style } - axeCore.run(node || document, options.runOptions, (error, results) => { + axeCore.run(node || options.element || document, options.runOptions, (error, results) => { if (error) deferred.reject(error) if (results && !results.violations.length) return if (JSON.stringify(results.violations) === lastNotification) return diff --git a/src/index.js b/src/index.js index fb15724..da03f1f 100644 --- a/src/index.js +++ b/src/index.js @@ -48,5 +48,5 @@ export default function install (Vue, options = {}) { }) // First check - setTimeout(() => draf(() => checkAndReport(options, document, 'App')), options.delay) + setTimeout(() => draf(() => checkAndReport(options, null, 'App')), options.delay) } diff --git a/src/utils.js b/src/utils.js index b32774e..e45bb74 100644 --- a/src/utils.js +++ b/src/utils.js @@ -7,6 +7,7 @@ export const defaultOptions = { allowConsoleClears: true, clearConsoleOnUpdate: false, delay: 500, + element: null, config: { branding: { application: 'vue-axe' From 3450f6556609f5732963eb34737f1729e0a0ef0b Mon Sep 17 00:00:00 2001 From: Jairo Valderrama Date: Fri, 8 Jul 2022 12:26:52 -0500 Subject: [PATCH 2/3] docs: demo running the audit on the first load against the mounting point It runs the audit against `document` with the manual run to check against an injected bug in the page head --- demo/public/index.html | 1 - demo/src/main.js | 4 +++- demo/src/views/Home.vue | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/demo/public/index.html b/demo/public/index.html index 4123528..e1ffed6 100644 --- a/demo/public/index.html +++ b/demo/public/index.html @@ -5,7 +5,6 @@ - <%= htmlWebpackPlugin.options.title %>