From 22de1a5a735e99b99183564043c038ce088e8014 Mon Sep 17 00:00:00 2001 From: michael-siek Date: Tue, 15 Oct 2019 13:56:32 -0400 Subject: [PATCH 1/6] fix(aria-allowed-role): allow role combobox on input tel, search, url, and email --- lib/commons/aria/index.js | 16 +++----- test/checks/aria/aria-allowed-role.js | 40 +++++++++++++++++++ .../aria-allowed-role/aria-allowed-role.html | 36 +++++++++++++++++ .../aria-allowed-role/aria-allowed-role.json | 4 ++ 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/lib/commons/aria/index.js b/lib/commons/aria/index.js index ebc240e181..d0d12e46ef 100644 --- a/lib/commons/aria/index.js +++ b/lib/commons/aria/index.js @@ -442,7 +442,7 @@ lookupTable.role = { { nodeName: 'input', properties: { - type: 'text' + type: ['text', 'search', 'tel', 'url', 'email'] } } ] @@ -2146,15 +2146,6 @@ lookupTable.elementsAllowedNoRole = [ ] } }, - { - nodeName: 'input', - attributes: { - list: isNull - }, - properties: { - type: ['email', 'search', 'tel', 'url'] - } - }, { nodeName: 'link', attributes: { @@ -2332,6 +2323,11 @@ lookupTable.evaluateRoleForElement = { return ( role === 'combobox' || role === 'searchbox' || role === 'spinbutton' ); + case 'tel': + case 'url': + case 'search': + case 'email': + return role === 'combobox'; default: return false; } diff --git a/test/checks/aria/aria-allowed-role.js b/test/checks/aria/aria-allowed-role.js index c7734a4cbd..be51cc70f4 100644 --- a/test/checks/aria/aria-allowed-role.js +++ b/test/checks/aria/aria-allowed-role.js @@ -127,6 +127,46 @@ describe('aria-allowed-role', function() { ); }); + it('returns true when INPUT type is tel with role combobox', function() { + var node = document.createElement('input'); + node.setAttribute('type', 'tel'); + node.setAttribute('role', 'combobox'); + fixture.appendChild(node); + assert.isTrue( + checks['aria-allowed-role'].evaluate.call(checkContext, node) + ); + }); + + it('returns true when INPUT type is url with role combobox', function() { + var node = document.createElement('input'); + node.setAttribute('type', 'url'); + node.setAttribute('role', 'combobox'); + fixture.appendChild(node); + assert.isTrue( + checks['aria-allowed-role'].evaluate.call(checkContext, node) + ); + }); + + it('returns true when INPUT type is search with role combobox', function() { + var node = document.createElement('input'); + node.setAttribute('type', 'search'); + node.setAttribute('role', 'combobox'); + fixture.appendChild(node); + assert.isTrue( + checks['aria-allowed-role'].evaluate.call(checkContext, node) + ); + }); + + it('returns true when INPUT type is email with role combobox', function() { + var node = document.createElement('input'); + node.setAttribute('type', 'email'); + node.setAttribute('role', 'combobox'); + fixture.appendChild(node); + assert.isTrue( + checks['aria-allowed-role'].evaluate.call(checkContext, node) + ); + }); + it('returns true when INPUT type is text with role spinbutton', function() { var node = document.createElement('input'); node.setAttribute('type', 'text'); diff --git a/test/integration/rules/aria-allowed-role/aria-allowed-role.html b/test/integration/rules/aria-allowed-role/aria-allowed-role.html index 5095ed00a6..f920c92b52 100644 --- a/test/integration/rules/aria-allowed-role/aria-allowed-role.html +++ b/test/integration/rules/aria-allowed-role/aria-allowed-role.html @@ -62,6 +62,42 @@

aria-expanded="true" id="pass-input-text-role-combobox" /> + + + + Date: Thu, 17 Oct 2019 08:25:47 -0400 Subject: [PATCH 2/6] fix(locale structure): structure message correct when building translations --- build/tasks/add-locale.js | 7 ++++--- lib/core/base/audit.js | 2 +- locales/de.json | 6 +----- locales/es.json | 6 +----- locales/fr.json | 6 +----- locales/ja.json | 6 +----- locales/nl.json | 6 +----- locales/pt_BR.json | 6 +----- test/core/public/configure.js | 6 +----- 9 files changed, 12 insertions(+), 39 deletions(-) diff --git a/build/tasks/add-locale.js b/build/tasks/add-locale.js index e3d662841d..afe85ec4e8 100644 --- a/build/tasks/add-locale.js +++ b/build/tasks/add-locale.js @@ -62,9 +62,10 @@ module.exports = function(grunt) { return out; }, {}), incompleteFallbackMessage: result.misc.reduce(function(out, misc) { - out[misc.incompleteFallbackMessage] = misc.metadata; - return out; - }, {}) + return misc.incompleteFallbackMessage + ? misc.incompleteFallbackMessage + : out; + }, '') }; // update locale file if exists diff --git a/lib/core/base/audit.js b/lib/core/base/audit.js index 9567f9fc34..9a27056c20 100644 --- a/lib/core/base/audit.js +++ b/lib/core/base/audit.js @@ -291,7 +291,7 @@ Audit.prototype.applyLocale = function(locale) { if (locale.incompleteFallbackMessage) { this.data.incompleteFallbackMessage = mergeFallbackMessage( this.data.incompleteFallbackMessage, - locale.incompleteFallbackMessage.undefined.failureMessage + locale.incompleteFallbackMessage ); } diff --git a/locales/de.json b/locales/de.json index f840403166..b96c8e8d64 100644 --- a/locales/de.json +++ b/locales/de.json @@ -619,9 +619,5 @@ "failureMessage": "Korrigiere alle der folgenden Punkte:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "" - } - } + "incompleteFallbackMessage": "" } diff --git a/locales/es.json b/locales/es.json index 00162e69fb..69e6fbd55a 100644 --- a/locales/es.json +++ b/locales/es.json @@ -769,9 +769,5 @@ "failureMessage": "Corregir (todas) las siguientes incidencias:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "Corregir (todas) las siguientes incidencias:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" - } - } + "incompleteFallbackMessage": "Corregir (todas) las siguientes incidencias:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } diff --git a/locales/fr.json b/locales/fr.json index ca786fcd4b..cf01a3e029 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -659,9 +659,5 @@ "failureMessage": "Corriger tous les éléments suivants : {{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "Corriger tous les éléments suivants : {{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" - } - } + "incompleteFallbackMessage": "Corriger tous les éléments suivants : {{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } diff --git a/locales/ja.json b/locales/ja.json index 15fda9a43f..fa72933eaa 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -778,9 +778,5 @@ "failureMessage": "次のすべてを修正します:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "次のすべてを修正します:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" - } - } + "incompleteFallbackMessage": "次のすべてを修正します:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } diff --git a/locales/nl.json b/locales/nl.json index 60e3681236..9008261be3 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -32,9 +32,5 @@ "failureMessage": "Gebruik een van de volgende oplossingen:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "axe kon de reden niet vertellen. Tijd om de element inspecteur uit te breken!" - } - } + "incompleteFallbackMessage": "axe kon de reden niet vertellen. Tijd om de element inspecteur uit te breken!" } diff --git a/locales/pt_BR.json b/locales/pt_BR.json index 0e771e5c0c..8f5e3e15c5 100644 --- a/locales/pt_BR.json +++ b/locales/pt_BR.json @@ -769,9 +769,5 @@ "failureMessage": "Corrija todos os itens a seguir:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } }, - "incompleteFallbackMessage": { - "undefined": { - "failureMessage": "Corrija todos os itens a seguir:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" - } - } + "incompleteFallbackMessage": "Corrija todos os itens a seguir:{{~it:value}}\n {{=value.split('\\n').join('\\n ')}}{{~}}" } diff --git a/test/core/public/configure.js b/test/core/public/configure.js index 83a3865735..98985c5255 100644 --- a/test/core/public/configure.js +++ b/test/core/public/configure.js @@ -393,11 +393,7 @@ describe('axe.configure', function() { failureMessage: 'bar' } }, - incompleteFallbackMessage: { - undefined: { - failureMessage: 'baz' - } - } + incompleteFallbackMessage: 'baz' } }); From f39e2e6de28ab6bac10711fd918ac9fbf55612e2 Mon Sep 17 00:00:00 2001 From: michael-siek Date: Thu, 17 Oct 2019 15:41:52 -0400 Subject: [PATCH 3/6] fix(possible merge conflict): revert the code to negate any merge conflicts --- lib/commons/aria/index.js | 34 +++++++--- test/checks/aria/aria-allowed-role.js | 67 +++++++++---------- .../aria-allowed-role/aria-allowed-role.html | 36 ---------- .../aria-allowed-role/aria-allowed-role.json | 4 -- 4 files changed, 56 insertions(+), 85 deletions(-) diff --git a/lib/commons/aria/index.js b/lib/commons/aria/index.js index d0d12e46ef..36369b033a 100644 --- a/lib/commons/aria/index.js +++ b/lib/commons/aria/index.js @@ -442,7 +442,7 @@ lookupTable.role = { { nodeName: 'input', properties: { - type: ['text', 'search', 'tel', 'url', 'email'] + type: 'text' } } ] @@ -2146,6 +2146,15 @@ lookupTable.elementsAllowedNoRole = [ ] } }, + { + nodeName: 'input', + attributes: { + list: isNull + }, + properties: { + type: ['email', 'search', 'tel', 'url'] + } + }, { nodeName: 'link', attributes: { @@ -2234,6 +2243,12 @@ lookupTable.elementsAllowedAnyRole = [ href: isNull } }, + { + nodeName: 'img', + attributes: { + alt: isNull + } + }, { nodeName: [ 'abbr', @@ -2301,11 +2316,15 @@ lookupTable.evaluateRoleForElement = { } return out; }, - IMG: ({ node, out }) => { - if (node.alt) { - return !out; + IMG: ({ node, role, out }) => { + switch (node.alt) { + case null: + return out; + case '': + return role === 'presentation' || role === 'none'; + default: + return role !== 'presentation' && role !== 'none'; } - return out; }, INPUT: ({ node, role, out }) => { switch (node.type) { @@ -2323,11 +2342,6 @@ lookupTable.evaluateRoleForElement = { return ( role === 'combobox' || role === 'searchbox' || role === 'spinbutton' ); - case 'tel': - case 'url': - case 'search': - case 'email': - return role === 'combobox'; default: return false; } diff --git a/test/checks/aria/aria-allowed-role.js b/test/checks/aria/aria-allowed-role.js index be51cc70f4..1874b6dfab 100644 --- a/test/checks/aria/aria-allowed-role.js +++ b/test/checks/aria/aria-allowed-role.js @@ -87,79 +87,76 @@ describe('aria-allowed-role', function() { ); }); - it('returns false when img has no alt', function() { + it('returns true when img has no alt', function() { var node = document.createElement('img'); node.setAttribute('role', 'presentation'); fixture.appendChild(node); - assert.isFalse( + assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); - assert.deepEqual(checkContext._data, ['presentation']); - }); - - it('returns true when input of type image and no role', function() { - var node = document.createElement('img'); - node.setAttribute('type', 'image'); - fixture.appendChild(node); + assert.deepEqual(checkContext._data, null); + node.setAttribute('role', 'none'); assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); - assert.isNull(checkContext._data, null); + assert.deepEqual(checkContext._data, null); }); - it('returns true when INPUT type is checkbox and has aria-pressed attribute', function() { - var node = document.createElement('input'); - node.setAttribute('type', 'checkbox'); - node.setAttribute('aria-pressed', ''); + it('returns true when img has empty alt', function() { + var node = document.createElement('img'); + node.setAttribute('alt', ''); + node.setAttribute('role', 'presentation'); fixture.appendChild(node); assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); - }); - - it('returns true when INPUT type is text with role combobox', function() { - var node = document.createElement('input'); - node.setAttribute('type', 'text'); - node.setAttribute('role', 'combobox'); - fixture.appendChild(node); + assert.deepEqual(checkContext._data, null); + node.setAttribute('role', 'none'); assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); + assert.deepEqual(checkContext._data, null); }); - it('returns true when INPUT type is tel with role combobox', function() { - var node = document.createElement('input'); - node.setAttribute('type', 'tel'); - node.setAttribute('role', 'combobox'); + it('returns false when img has alt', function() { + var node = document.createElement('img'); + node.setAttribute('alt', 'not empty'); + node.setAttribute('role', 'presentation'); fixture.appendChild(node); - assert.isTrue( + assert.isFalse( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); + assert.deepEqual(checkContext._data, ['presentation']); + node.setAttribute('role', 'none'); + assert.isFalse( + checks['aria-allowed-role'].evaluate.call(checkContext, node) + ); + assert.deepEqual(checkContext._data, ['none']); }); - it('returns true when INPUT type is url with role combobox', function() { - var node = document.createElement('input'); - node.setAttribute('type', 'url'); - node.setAttribute('role', 'combobox'); + it('returns true when input of type image and no role', function() { + var node = document.createElement('img'); + node.setAttribute('type', 'image'); fixture.appendChild(node); assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); + assert.isNull(checkContext._data, null); }); - it('returns true when INPUT type is search with role combobox', function() { + it('returns true when INPUT type is checkbox and has aria-pressed attribute', function() { var node = document.createElement('input'); - node.setAttribute('type', 'search'); - node.setAttribute('role', 'combobox'); + node.setAttribute('type', 'checkbox'); + node.setAttribute('aria-pressed', ''); fixture.appendChild(node); assert.isTrue( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); }); - it('returns true when INPUT type is email with role combobox', function() { + it('returns true when INPUT type is text with role combobox', function() { var node = document.createElement('input'); - node.setAttribute('type', 'email'); + node.setAttribute('type', 'text'); node.setAttribute('role', 'combobox'); fixture.appendChild(node); assert.isTrue( diff --git a/test/integration/rules/aria-allowed-role/aria-allowed-role.html b/test/integration/rules/aria-allowed-role/aria-allowed-role.html index f920c92b52..5095ed00a6 100644 --- a/test/integration/rules/aria-allowed-role/aria-allowed-role.html +++ b/test/integration/rules/aria-allowed-role/aria-allowed-role.html @@ -62,42 +62,6 @@

aria-expanded="true" id="pass-input-text-role-combobox" /> - - - - Date: Thu, 17 Oct 2019 15:52:14 -0400 Subject: [PATCH 4/6] fix(possible merge conflict): revert the code to negate any merge conflicts From 93726879dcf70fd9c9d2659445a5a22ab5a9cbd0 Mon Sep 17 00:00:00 2001 From: michael-siek Date: Fri, 18 Oct 2019 07:59:28 -0400 Subject: [PATCH 5/6] fix: ci failing due to prior commits --- test/checks/aria/aria-allowed-role.js | 39 +-------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/test/checks/aria/aria-allowed-role.js b/test/checks/aria/aria-allowed-role.js index 1874b6dfab..c7734a4cbd 100644 --- a/test/checks/aria/aria-allowed-role.js +++ b/test/checks/aria/aria-allowed-role.js @@ -87,51 +87,14 @@ describe('aria-allowed-role', function() { ); }); - it('returns true when img has no alt', function() { + it('returns false when img has no alt', function() { var node = document.createElement('img'); node.setAttribute('role', 'presentation'); fixture.appendChild(node); - assert.isTrue( - checks['aria-allowed-role'].evaluate.call(checkContext, node) - ); - assert.deepEqual(checkContext._data, null); - node.setAttribute('role', 'none'); - assert.isTrue( - checks['aria-allowed-role'].evaluate.call(checkContext, node) - ); - assert.deepEqual(checkContext._data, null); - }); - - it('returns true when img has empty alt', function() { - var node = document.createElement('img'); - node.setAttribute('alt', ''); - node.setAttribute('role', 'presentation'); - fixture.appendChild(node); - assert.isTrue( - checks['aria-allowed-role'].evaluate.call(checkContext, node) - ); - assert.deepEqual(checkContext._data, null); - node.setAttribute('role', 'none'); - assert.isTrue( - checks['aria-allowed-role'].evaluate.call(checkContext, node) - ); - assert.deepEqual(checkContext._data, null); - }); - - it('returns false when img has alt', function() { - var node = document.createElement('img'); - node.setAttribute('alt', 'not empty'); - node.setAttribute('role', 'presentation'); - fixture.appendChild(node); assert.isFalse( checks['aria-allowed-role'].evaluate.call(checkContext, node) ); assert.deepEqual(checkContext._data, ['presentation']); - node.setAttribute('role', 'none'); - assert.isFalse( - checks['aria-allowed-role'].evaluate.call(checkContext, node) - ); - assert.deepEqual(checkContext._data, ['none']); }); it('returns true when input of type image and no role', function() { From c2ba7c8a615f2ece381b25e7242646946ada15bd Mon Sep 17 00:00:00 2001 From: michael-siek Date: Fri, 18 Oct 2019 08:08:58 -0400 Subject: [PATCH 6/6] fix: reverting files due to prior commit --- lib/commons/aria/index.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/commons/aria/index.js b/lib/commons/aria/index.js index 36369b033a..ebc240e181 100644 --- a/lib/commons/aria/index.js +++ b/lib/commons/aria/index.js @@ -2243,12 +2243,6 @@ lookupTable.elementsAllowedAnyRole = [ href: isNull } }, - { - nodeName: 'img', - attributes: { - alt: isNull - } - }, { nodeName: [ 'abbr', @@ -2316,15 +2310,11 @@ lookupTable.evaluateRoleForElement = { } return out; }, - IMG: ({ node, role, out }) => { - switch (node.alt) { - case null: - return out; - case '': - return role === 'presentation' || role === 'none'; - default: - return role !== 'presentation' && role !== 'none'; + IMG: ({ node, out }) => { + if (node.alt) { + return !out; } + return out; }, INPUT: ({ node, role, out }) => { switch (node.type) {