|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | exports.__esModule = true;
|
|---|
| 4 | exports.default = void 0;
|
|---|
| 5 | const elements = ['svg', 'Svg'];
|
|---|
| 6 |
|
|---|
| 7 | const plugin = ({
|
|---|
| 8 | types: t
|
|---|
| 9 | }) => ({
|
|---|
| 10 | visitor: {
|
|---|
| 11 | JSXOpeningElement: {
|
|---|
| 12 | enter(path) {
|
|---|
| 13 | if (!elements.some(element => path.get('name').isJSXIdentifier({
|
|---|
| 14 | name: element
|
|---|
| 15 | }))) return;
|
|---|
| 16 | const requiredAttributes = ['width', 'height'];
|
|---|
| 17 | const attributeValue = '1em';
|
|---|
| 18 | path.get('attributes').forEach(attributePath => {
|
|---|
| 19 | if (!attributePath.isJSXAttribute()) return;
|
|---|
| 20 | const index = requiredAttributes.indexOf(attributePath.node.name.name);
|
|---|
| 21 | if (index === -1) return;
|
|---|
| 22 | const value = attributePath.get('value');
|
|---|
| 23 | value.replaceWith(t.stringLiteral(attributeValue));
|
|---|
| 24 | requiredAttributes.splice(index, 1);
|
|---|
| 25 | });
|
|---|
| 26 | requiredAttributes.forEach(attribute => {
|
|---|
| 27 | path.pushContainer('attributes', t.jsxAttribute(t.jsxIdentifier(attribute), t.stringLiteral(attributeValue)));
|
|---|
| 28 | });
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 | });
|
|---|
| 34 |
|
|---|
| 35 | var _default = plugin;
|
|---|
| 36 | exports.default = _default; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.