|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
952 bytes
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports["default"] = getTabIndex;
|
|---|
| 7 | var _jsxAstUtils = require("jsx-ast-utils");
|
|---|
| 8 | /**
|
|---|
| 9 | * Returns the tabIndex value.
|
|---|
| 10 | */
|
|---|
| 11 | function getTabIndex(tabIndex) {
|
|---|
| 12 | var literalValue = (0, _jsxAstUtils.getLiteralPropValue)(tabIndex);
|
|---|
| 13 |
|
|---|
| 14 | // String and number values.
|
|---|
| 15 | if (['string', 'number'].indexOf(typeof literalValue) > -1) {
|
|---|
| 16 | // Empty string will convert to zero, so check for it explicity.
|
|---|
| 17 | if (typeof literalValue === 'string' && literalValue.length === 0) {
|
|---|
| 18 | return undefined;
|
|---|
| 19 | }
|
|---|
| 20 | var value = Number(literalValue);
|
|---|
| 21 | if (Number.isNaN(value)) {
|
|---|
| 22 | return undefined;
|
|---|
| 23 | }
|
|---|
| 24 | return Number.isInteger(value) ? value : undefined;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | // Booleans are not valid values, return undefined.
|
|---|
| 28 | if (literalValue === true || literalValue === false) {
|
|---|
| 29 | return undefined;
|
|---|
| 30 | }
|
|---|
| 31 | return (0, _jsxAstUtils.getPropValue)(tabIndex);
|
|---|
| 32 | }
|
|---|
| 33 | module.exports = exports.default; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.