Sha256: f83120401b3a647a27cdb8098344df3bd0f26f3697b6d3756c88c725d7132b66

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = elementType;
function resolveMemberExpressions() {
  var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var property = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  if (object.type === 'JSXMemberExpression') {
    return resolveMemberExpressions(object.object, object.property) + '.' + property.name;
  }

  return object.name + '.' + property.name;
}

/**
 * Returns the tagName associated with a JSXElement.
 */
function elementType() {
  var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var name = node.name;


  if (node.type === 'JSXOpeningFragment') {
    return '<>';
  }

  if (!name) {
    throw new Error('The argument provided is not a JSXElement node.');
  }

  if (name.type === 'JSXMemberExpression') {
    var _name$object = name.object,
        object = _name$object === undefined ? {} : _name$object,
        _name$property = name.property,
        property = _name$property === undefined ? {} : _name$property;

    return resolveMemberExpressions(object, property);
  }

  if (name.type === 'JSXNamespacedName') {
    return name.namespace.name + ':' + name.name.name;
  }

  return node.name.name;
}

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.51 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.50 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.49 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.48 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.47 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.46 node_modules/jsx-ast-utils/lib/elementType.js
immosquare-cleaner-0.1.45 node_modules/jsx-ast-utils/lib/elementType.js
decidim-0.26.8 packages/eslint-config/node_modules/jsx-ast-utils/lib/elementType.js