mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer): finish transform jsx attribute value (#1078)
This commit is contained in:
parent
5fb27fbe8a
commit
d411258be4
2 changed files with 13 additions and 17 deletions
|
|
@ -353,27 +353,25 @@ impl<'a> ReactJsx<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transform_jsx_attribute_value(
|
fn transform_jsx_attribute_value(
|
||||||
&self,
|
&mut self,
|
||||||
value: Option<&JSXAttributeValue<'a>>,
|
value: Option<&JSXAttributeValue<'a>>,
|
||||||
) -> Option<Expression<'a>> {
|
) -> Option<Expression<'a>> {
|
||||||
match value {
|
match value {
|
||||||
Some(JSXAttributeValue::StringLiteral(s)) => {
|
Some(JSXAttributeValue::StringLiteral(s)) => {
|
||||||
Some(self.ast.literal_string_expression(s.clone()))
|
Some(self.ast.literal_string_expression(s.clone()))
|
||||||
}
|
}
|
||||||
Some(JSXAttributeValue::Element(_) | JSXAttributeValue::Fragment(_)) => {
|
Some(JSXAttributeValue::Element(e)) => {
|
||||||
/* TODO */
|
self.transform_jsx(&JSXElementOrFragment::Element(e))
|
||||||
None
|
|
||||||
}
|
}
|
||||||
Some(JSXAttributeValue::ExpressionContainer(c)) => {
|
Some(JSXAttributeValue::Fragment(e)) => {
|
||||||
match &c.expression {
|
self.transform_jsx(&JSXElementOrFragment::Fragment(e))
|
||||||
JSXExpression::Expression(e) => Some(self.ast.copy(e)),
|
}
|
||||||
JSXExpression::EmptyExpression(_e) =>
|
Some(JSXAttributeValue::ExpressionContainer(c)) => match &c.expression {
|
||||||
/* TODO */
|
JSXExpression::Expression(e) => Some(self.ast.copy(e)),
|
||||||
{
|
JSXExpression::EmptyExpression(_e) => {
|
||||||
None
|
Some(self.ast.literal_boolean_expression(BooleanLiteral::new(SPAN, true)))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
None => Some(self.ast.literal_boolean_expression(BooleanLiteral::new(SPAN, true))),
|
None => Some(self.ast.literal_boolean_expression(BooleanLiteral::new(SPAN, true))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Passed: 215/1083
|
Passed: 217/1083
|
||||||
|
|
||||||
# All Passed:
|
# All Passed:
|
||||||
* babel-plugin-transform-numeric-separator
|
* babel-plugin-transform-numeric-separator
|
||||||
|
|
@ -804,7 +804,7 @@ Passed: 215/1083
|
||||||
* regression/11061/input.mjs
|
* regression/11061/input.mjs
|
||||||
* variable-declaration/non-null-in-optional-chain/input.ts
|
* variable-declaration/non-null-in-optional-chain/input.ts
|
||||||
|
|
||||||
# babel-plugin-transform-react-jsx (66/172)
|
# babel-plugin-transform-react-jsx (68/172)
|
||||||
* autoImport/after-polyfills/input.mjs
|
* autoImport/after-polyfills/input.mjs
|
||||||
* autoImport/after-polyfills-2/input.mjs
|
* autoImport/after-polyfills-2/input.mjs
|
||||||
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
|
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
|
||||||
|
|
@ -846,7 +846,6 @@ Passed: 215/1083
|
||||||
* react/optimisation.react.constant-elements/input.js
|
* react/optimisation.react.constant-elements/input.js
|
||||||
* react/pragma-works-with-no-space-at-the-end/input.js
|
* react/pragma-works-with-no-space-at-the-end/input.js
|
||||||
* react/should-add-quotes-es3/input.js
|
* react/should-add-quotes-es3/input.js
|
||||||
* react/should-allow-elements-as-attributes/input.js
|
|
||||||
* react/should-allow-jsx-docs-comment-with-pragma/input.js
|
* react/should-allow-jsx-docs-comment-with-pragma/input.js
|
||||||
* react/should-allow-no-pragmafrag-if-frag-unused/input.js
|
* react/should-allow-no-pragmafrag-if-frag-unused/input.js
|
||||||
* react/should-allow-pragmafrag-and-frag/input.js
|
* react/should-allow-pragmafrag-and-frag/input.js
|
||||||
|
|
@ -878,7 +877,6 @@ Passed: 215/1083
|
||||||
* react-automatic/optimisation.react.constant-elements/input.js
|
* react-automatic/optimisation.react.constant-elements/input.js
|
||||||
* react-automatic/pragma-works-with-no-space-at-the-end/input.js
|
* react-automatic/pragma-works-with-no-space-at-the-end/input.js
|
||||||
* react-automatic/should-add-quotes-es3/input.js
|
* react-automatic/should-add-quotes-es3/input.js
|
||||||
* react-automatic/should-allow-elements-as-attributes/input.js
|
|
||||||
* react-automatic/should-allow-nested-fragments/input.js
|
* react-automatic/should-allow-nested-fragments/input.js
|
||||||
* react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js
|
* react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js
|
||||||
* react-automatic/should-disallow-valueless-key/input.js
|
* react-automatic/should-disallow-valueless-key/input.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue