@svgr/babel-plugin-add-jsx-attribute
Advanced tools
Comparing version 6.5.0 to 6.5.1
@@ -6,32 +6,22 @@ # Change Log | ||
# [6.5.0](https://github.com/gregberge/svgr/compare/v6.4.0...v6.5.0) (2022-10-14) | ||
## [6.5.1](https://github.com/gregberge/svgr/compare/v6.5.0...v6.5.1) (2022-10-27) | ||
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute | ||
# [6.5.0](https://github.com/gregberge/svgr/compare/v6.4.0...v6.5.0) (2022-10-14) | ||
**Note:** Version bump only for package @svgr/babel-plugin-add-jsx-attribute | ||
## [6.3.1](https://github.com/gregberge/svgr/compare/v6.3.0...v6.3.1) (2022-07-22) | ||
### Bug Fixes | ||
* fix exports compat with ESM ([#749](https://github.com/gregberge/svgr/issues/749)) ([f3e304c](https://github.com/gregberge/svgr/commit/f3e304c166282f042ecd4d6c396a0798a7f0b490)) | ||
- fix exports compat with ESM ([#749](https://github.com/gregberge/svgr/issues/749)) ([f3e304c](https://github.com/gregberge/svgr/commit/f3e304c166282f042ecd4d6c396a0798a7f0b490)) | ||
# [6.3.0](https://github.com/gregberge/svgr/compare/v6.2.1...v6.3.0) (2022-07-18) | ||
### Bug Fixes | ||
* **package.json:** fix exports ([#745](https://github.com/gregberge/svgr/issues/745)) ([2a368d1](https://github.com/gregberge/svgr/commit/2a368d1305949ec6426c7c7312c04224071ec2bd)) | ||
- **package.json:** fix exports ([#745](https://github.com/gregberge/svgr/issues/745)) ([2a368d1](https://github.com/gregberge/svgr/commit/2a368d1305949ec6426c7c7312c04224071ec2bd)) | ||
# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v5.3.1...v5.4.0) (2020-04-27) | ||
@@ -41,17 +31,8 @@ | ||
## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v5.0.0...v5.0.1) (2019-12-29) | ||
### Bug Fixes | ||
* fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7)) | ||
- fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7)) | ||
# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/babel-plugin-add-jsx-attribute/compare/v4.1.0...v4.2.0) (2019-04-11) | ||
@@ -61,17 +42,12 @@ | ||
# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04) | ||
### Features | ||
* **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca)) | ||
- **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca)) | ||
### BREAKING CHANGES | ||
* **v4:** - `template` option must now returns a Babel AST | ||
- `@svgr/core` does not include svgo & prettier by default | ||
- **v4:** - `template` option must now returns a Babel AST | ||
* `@svgr/core` does not include svgo & prettier by default |
@@ -21,3 +21,5 @@ 'use strict'; | ||
if (typeof value === "string" && literal) { | ||
return core.types.jsxExpressionContainer(core.template.ast(value).expression); | ||
return core.types.jsxExpressionContainer( | ||
core.template.ast(value).expression | ||
); | ||
} | ||
@@ -33,3 +35,6 @@ if (typeof value === "string") { | ||
} | ||
return core.types.jsxAttribute(core.types.jsxIdentifier(name), getAttributeValue({ value, literal })); | ||
return core.types.jsxAttribute( | ||
core.types.jsxIdentifier(name), | ||
getAttributeValue({ value, literal }) | ||
); | ||
} | ||
@@ -43,27 +48,29 @@ return { | ||
return; | ||
opts.attributes.forEach(({ | ||
name, | ||
value = null, | ||
spread = false, | ||
literal = false, | ||
position = "end" | ||
}) => { | ||
const method = positionMethod[position]; | ||
const newAttribute = getAttribute({ spread, name, value, literal }); | ||
const attributes = path.get("attributes"); | ||
const isEqualAttribute = (attribute) => { | ||
if (spread) | ||
return attribute.isJSXSpreadAttribute() && attribute.get("argument").isIdentifier({ name }); | ||
return attribute.isJSXAttribute() && attribute.get("name").isJSXIdentifier({ name }); | ||
}; | ||
const replaced = attributes.some((attribute) => { | ||
if (!isEqualAttribute(attribute)) | ||
return false; | ||
attribute.replaceWith(newAttribute); | ||
return true; | ||
}); | ||
if (!replaced) { | ||
path[method]("attributes", newAttribute); | ||
opts.attributes.forEach( | ||
({ | ||
name, | ||
value = null, | ||
spread = false, | ||
literal = false, | ||
position = "end" | ||
}) => { | ||
const method = positionMethod[position]; | ||
const newAttribute = getAttribute({ spread, name, value, literal }); | ||
const attributes = path.get("attributes"); | ||
const isEqualAttribute = (attribute) => { | ||
if (spread) | ||
return attribute.isJSXSpreadAttribute() && attribute.get("argument").isIdentifier({ name }); | ||
return attribute.isJSXAttribute() && attribute.get("name").isJSXIdentifier({ name }); | ||
}; | ||
const replaced = attributes.some((attribute) => { | ||
if (!isEqualAttribute(attribute)) | ||
return false; | ||
attribute.replaceWith(newAttribute); | ||
return true; | ||
}); | ||
if (!replaced) { | ||
path[method]("attributes", newAttribute); | ||
} | ||
} | ||
}); | ||
); | ||
} | ||
@@ -70,0 +77,0 @@ } |
{ | ||
"name": "@svgr/babel-plugin-add-jsx-attribute", | ||
"description": "Add JSX attribute", | ||
"version": "6.5.0", | ||
"version": "6.5.1", | ||
"main": "./dist/index.js", | ||
@@ -39,3 +39,3 @@ "types": "./dist/index.d.ts", | ||
}, | ||
"gitHead": "b385279d27e51d34e4684dda326aa4216a485572" | ||
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13155
98