amp-attributes.js 950 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = AmpAttributePatcher;
  6. function AmpAttributePatcher() {
  7. return {
  8. visitor: {
  9. JSXOpeningElement (path) {
  10. const openingElement = path.node;
  11. const { name , attributes } = openingElement;
  12. if (!(name && name.type === "JSXIdentifier")) {
  13. return;
  14. }
  15. if (!name.name.startsWith("amp-")) {
  16. return;
  17. }
  18. for (const attribute of attributes){
  19. if (attribute.type !== "JSXAttribute") {
  20. continue;
  21. }
  22. if (attribute.name.name === "className") {
  23. attribute.name.name = "class";
  24. }
  25. }
  26. }
  27. }
  28. };
  29. }
  30. //# sourceMappingURL=amp-attributes.js.map