Sha256: 632609c21c0f187aa043c65851c3f70a57a8bfa59ff823ec44c1165abae4f5b9

Contents?: true

Size: 1.16 KB

Versions: 44

Compression:

Stored size: 1.16 KB

Contents

'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = getProp;

var _propName = require('./propName');

var _propName2 = _interopRequireDefault(_propName);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DEFAULT_OPTIONS = {
  ignoreCase: true
};

/**
 * Returns the JSXAttribute itself or undefined, indicating the prop
 * is not present on the JSXOpeningElement.
 *
 */
function getProp() {
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;

  var propToFind = options.ignoreCase ? prop.toUpperCase() : prop;

  return props.find(function (attribute) {
    // If the props contain a spread prop, then skip.
    if (attribute.type === 'JSXSpreadAttribute') {
      return false;
    }

    var currentProp = options.ignoreCase ? (0, _propName2.default)(attribute).toUpperCase() : (0, _propName2.default)(attribute);

    return propToFind === currentProp;
  });
}

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.21.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.20.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.19.1 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.19.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.18.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.17.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.16.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.15.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.14.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.13.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.12.2 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.12.1 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.12.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.11.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.10.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.9.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.8.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.7.0 node_modules/jsx-ast-utils/lib/getProp.js
govuk_publishing_components-17.6.1 node_modules/jsx-ast-utils/lib/getProp.js