JSXElement.js 625 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = extractValueFromJSXElement;
  6. /**
  7. * Extractor function for a JSXElement type value node.
  8. *
  9. * Returns self-closing element with correct name.
  10. */
  11. function extractValueFromJSXElement(value) {
  12. // eslint-disable-next-line global-require
  13. var getValue = require('.').default;
  14. var Tag = value.openingElement.name.name;
  15. if (value.openingElement.selfClosing) {
  16. return '<' + Tag + ' />';
  17. }
  18. return '<' + Tag + '>' + [].concat(value.children).map(function (x) {
  19. return getValue(x);
  20. }).join('') + '</' + Tag + '>';
  21. }