| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports["default"] = void 0;
|
|---|
| 7 | var _jsxAstUtils = require("jsx-ast-utils");
|
|---|
| 8 | var _getElementType = _interopRequireDefault(require("../util/getElementType"));
|
|---|
| 9 | var _schemas = require("../util/schemas");
|
|---|
| 10 | function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|---|
| 11 | /**
|
|---|
| 12 | * @fileoverview Enforce iframe elements have a title attribute.
|
|---|
| 13 | * @author Ethan Cohen
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | // ----------------------------------------------------------------------------
|
|---|
| 17 | // Rule Definition
|
|---|
| 18 | // ----------------------------------------------------------------------------
|
|---|
| 19 |
|
|---|
| 20 | var errorMessage = '<iframe> elements must have a unique title property.';
|
|---|
| 21 | var schema = (0, _schemas.generateObjSchema)();
|
|---|
| 22 | var _default = exports["default"] = {
|
|---|
| 23 | meta: {
|
|---|
| 24 | docs: {
|
|---|
| 25 | url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md',
|
|---|
| 26 | description: 'Enforce iframe elements have a title attribute.'
|
|---|
| 27 | },
|
|---|
| 28 | schema: [schema]
|
|---|
| 29 | },
|
|---|
| 30 | create: function create(context) {
|
|---|
| 31 | var elementType = (0, _getElementType["default"])(context);
|
|---|
| 32 | return {
|
|---|
| 33 | JSXOpeningElement: function JSXOpeningElement(node) {
|
|---|
| 34 | var type = elementType(node);
|
|---|
| 35 | if (type && type !== 'iframe') {
|
|---|
| 36 | return;
|
|---|
| 37 | }
|
|---|
| 38 | var title = (0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(node.attributes, 'title'));
|
|---|
| 39 | if (title && typeof title === 'string') {
|
|---|
| 40 | return;
|
|---|
| 41 | }
|
|---|
| 42 | context.report({
|
|---|
| 43 | node,
|
|---|
| 44 | message: errorMessage
|
|---|
| 45 | });
|
|---|
| 46 | }
|
|---|
| 47 | };
|
|---|
| 48 | }
|
|---|
| 49 | };
|
|---|
| 50 | module.exports = exports.default; |
|---|