- Item 1
- Item 2 @@ -66,12 +58,17 @@ function setup() {
diff --git a/.github/workflows/accessibility-alt-text.yml b/.github/workflows/accessibility-alt-text.yml
new file mode 100644
index 00000000..2b8ea3f1
--- /dev/null
+++ b/.github/workflows/accessibility-alt-text.yml
@@ -0,0 +1,28 @@
+name: Accessibility-alt-text-bot
+on:
+ issues:
+ types: [opened, edited]
+ pull_request:
+ types: [opened, edited]
+ issue_comment:
+ types: [created, edited]
+ discussion:
+ types: [created, edited]
+ discussion_comment:
+ types: [created, edited]
+
+permissions:
+ issues: write
+ pull-requests: write
+ discussions: write
+
+jobs:
+ accessibility_alt_text_bot:
+ name: Check alt text is set on issue or pull requests
+ runs-on: ubuntu-latest
+ if:
+ ${{ github.event.issue || github.event.pull_request ||
+ github.event.discussion }}
+ steps:
+ - name: Get action 'github/accessibility-alt-text-bot'
+ uses: github/accessibility-alt-text-bot@v1.2.0 # Set to latest
diff --git a/package.json b/package.json
index 83d2ab26..b186a6cb 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^5.0.1",
- "aria-query": "5.1.3",
+ "aria-query": "5.3.0",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.5.0",
diff --git a/src/__tests__/__snapshots__/role-helpers.js.snap b/src/__tests__/__snapshots__/role-helpers.js.snap
index 4a8a1f2f..75bbed7f 100644
--- a/src/__tests__/__snapshots__/role-helpers.js.snap
+++ b/src/__tests__/__snapshots__/role-helpers.js.snap
@@ -52,32 +52,6 @@ Name "":
data-testid="a-article"
/>
---------------------------------------------------
-command:
-
-Name "":
-
-
-Name "":
-
-
---------------------------------------------------
-menuitem:
-
-Name "":
-
-
-Name "":
-
-
--------------------------------------------------
list:
@@ -216,5 +190,31 @@ Name "":
data-testid="a-dd"
/>
+--------------------------------------------------
+img:
+
+Name "":
+
+
+Name "a meaningful description":
+
+
+--------------------------------------------------
+presentation:
+
+Name "":
+
+
--------------------------------------------------
`;
diff --git a/src/__tests__/role-helpers.js b/src/__tests__/role-helpers.js
index aadc1dc2..1ed32464 100644
--- a/src/__tests__/role-helpers.js
+++ b/src/__tests__/role-helpers.js
@@ -19,7 +19,7 @@ function setup() {
Tertiary Heading
-
+
+
+
+
+
+
+
+ Loading ... (1) -
+ `) @@ -214,7 +214,7 @@ test('escapes regular expressions in suggestion', () => { ).toString(), ).toEqual(`getByAltText(/the problem \\(picture of a question mark\\)/i)`) - expect(getSuggestedQuery(container.querySelector('p')).toString()).toEqual( + expect(getSuggestedQuery(container.querySelector('span')).toString()).toEqual( `getByText(/loading \\.\\.\\. \\(1\\)/i)`, ) diff --git a/src/role-helpers.js b/src/role-helpers.js index bc134f27..8d7e7cb0 100644 --- a/src/role-helpers.js +++ b/src/role-helpers.js @@ -82,13 +82,18 @@ function buildElementRoleList(elementRolesMap) { return `${name}${attributes .map(({name: attributeName, value, constraints = []}) => { const shouldNotExist = constraints.indexOf('undefined') !== -1 - if (shouldNotExist) { - return `:not([${attributeName}])` - } else if (value) { + const shouldBeNonEmpty = constraints.indexOf('set') !== -1 + const hasExplicitValue = typeof value !== 'undefined' + + if (hasExplicitValue) { return `[${attributeName}="${value}"]` - } else { - return `[${attributeName}]` + } else if (shouldNotExist) { + return `:not([${attributeName}])` + } else if (shouldBeNonEmpty) { + return `[${attributeName}]:not([${attributeName}=""])` } + + return `[${attributeName}]` }) .join('')}` }