jsx.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. export default (function () {
  2. var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
  3. return function createRawReactElement(type, props, key, children) {
  4. var defaultProps = type && type.defaultProps;
  5. var childrenLength = arguments.length - 3;
  6. if (!props && childrenLength !== 0) {
  7. props = {};
  8. }
  9. if (props && defaultProps) {
  10. for (var propName in defaultProps) {
  11. if (props[propName] === void 0) {
  12. props[propName] = defaultProps[propName];
  13. }
  14. }
  15. } else if (!props) {
  16. props = defaultProps || {};
  17. }
  18. if (childrenLength === 1) {
  19. props.children = children;
  20. } else if (childrenLength > 1) {
  21. var childArray = Array(childrenLength);
  22. for (var i = 0; i < childrenLength; i++) {
  23. childArray[i] = arguments[i + 3];
  24. }
  25. props.children = childArray;
  26. }
  27. return {
  28. $$typeof: REACT_ELEMENT_TYPE,
  29. type: type,
  30. key: key === undefined ? null : '' + key,
  31. ref: null,
  32. props: props,
  33. _owner: null
  34. };
  35. };
  36. })();