web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
665 B

  1. import toAST from 'to-ast'; // eslint-disable-line import/no-extraneous-dependencies
  2. import JSXExpressionContainerMock from './JSXExpressionContainerMock';
  3. export default function JSXAttributeMock(prop, value, isExpressionContainer = false) {
  4. let astValue;
  5. if (value && value.type !== undefined) {
  6. astValue = value;
  7. } else {
  8. astValue = toAST(value);
  9. }
  10. let attributeValue = astValue;
  11. if (isExpressionContainer || astValue.type !== 'Literal') {
  12. attributeValue = JSXExpressionContainerMock(astValue);
  13. }
  14. return {
  15. type: 'JSXAttribute',
  16. name: {
  17. type: 'JSXIdentifier',
  18. name: prop,
  19. },
  20. value: attributeValue,
  21. };
  22. }