- commit
- 6284c520f8f9a543a061ce619f538e68450ecafa
- parent
- f5c9394abea83a77d554a2b02bea59698dc5fdbb
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-01-08 07:16
Merge pull request #11 from xi/fix-img-presentation fix: img[alt=""] has role presentatio
Diffstat
| M | lib/constants.js | 3 | +++ |
| M | lib/name.js | 2 | +- |
| M | test/test-name.js | 6 | ++++++ |
3 files changed, 10 insertions, 1 deletions
diff --git a/lib/constants.js b/lib/constants.js
@@ -295,6 +295,9 @@ exports.roles = {
295 295 'selected': 'false',
296 296 },
297 297 },
-1 298 presentation: {
-1 299 selectors: ['img[alt=""]'],
-1 300 },
298 301 progressbar: {
299 302 selectors: ['progress'],
300 303 },
diff --git a/lib/name.js b/lib/name.js
@@ -149,7 +149,7 @@ var getName = function(el, recursive, visited, directReference) {
149 149
150 150 // I
151 151 // FIXME: presentation not mentioned in the spec
152 -1 if (!ret.trim() && !query.matches(el, 'presentation')) {
-1 152 if (!ret.trim() && (directReference || !query.matches(el, 'presentation'))) {
153 153 ret = el.title || '';
154 154 }
155 155
diff --git a/test/test-name.js b/test/test-name.js
@@ -28,4 +28,10 @@ describe('getName / getDescription', function() {
28 28 var element = document.querySelector('#test');
29 29 expect(aria.getName(element)).toBe('test');
30 30 });
-1 31
-1 32 it('ignores <img alt="">', function() {
-1 33 testbed.innerHTML = '<img id="test" alt="" title="title">'
-1 34 var element = document.querySelector('#test');
-1 35 expect(aria.getName(element)).toBe('');
-1 36 });
31 37 });