|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Rev | Line | |
|---|
| [9af201e] | 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports["default"] = getImplicitRoleForImg;
|
|---|
| 7 | var _jsxAstUtils = require("jsx-ast-utils");
|
|---|
| 8 | /**
|
|---|
| 9 | * Returns the implicit role for an img tag.
|
|---|
| 10 | */
|
|---|
| 11 | function getImplicitRoleForImg(attributes) {
|
|---|
| 12 | var _getLiteralPropValue;
|
|---|
| 13 | var alt = (0, _jsxAstUtils.getProp)(attributes, 'alt');
|
|---|
| 14 | if (alt && (0, _jsxAstUtils.getLiteralPropValue)(alt) === '') {
|
|---|
| 15 | return '';
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * If the src attribute can be determined to be an svg, allow the role to be set to 'img'
|
|---|
| 20 | * so that VoiceOver on Safari can be better supported.
|
|---|
| 21 | *
|
|---|
| 22 | * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#identifying_svg_as_an_image
|
|---|
| 23 | * @see https://bugs.webkit.org/show_bug.cgi?id=216364
|
|---|
| 24 | */
|
|---|
| 25 | var src = (0, _jsxAstUtils.getProp)(attributes, 'src');
|
|---|
| 26 | if (src && (_getLiteralPropValue = (0, _jsxAstUtils.getLiteralPropValue)(src)) !== null && _getLiteralPropValue !== void 0 && _getLiteralPropValue.includes('.svg')) {
|
|---|
| 27 | return '';
|
|---|
| 28 | }
|
|---|
| 29 | return 'img';
|
|---|
| 30 | }
|
|---|
| 31 | module.exports = exports.default; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.