Skip to content

Commit

Permalink
feat(transformer/react-jsx): support @jsxFrag annotation (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 8, 2023
1 parent 26fd006 commit 28c0b85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 15 additions & 2 deletions crates/oxc_transformer/src/react_jsx/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,27 @@ impl ReactJsxOptions {

// read jsxRuntime
match comment.strip_prefix("jsxRuntime").map(str::trim) {
Some("classic") => self.runtime = ReactJsxRuntime::Classic,
Some("automatic") => self.runtime = ReactJsxRuntime::Automatic,
Some("classic") => {
self.runtime = ReactJsxRuntime::Classic;
continue;
}
Some("automatic") => {
self.runtime = ReactJsxRuntime::Automatic;
continue;
}
_ => {}
}

// read jsxImportSource
if let Some(import_source) = comment.strip_prefix("jsxImportSource").map(str::trim) {
self.import_source = Cow::from(import_source.to_string());
continue;
}

// read jsxFrag
if let Some(pragma_frag) = comment.strip_prefix("jsxFrag").map(str::trim) {
self.pragma_frag = Cow::from(pragma_frag.to_string());
continue;
}

// Put this condition at the end to avoid breaking @jsxXX
Expand Down
7 changes: 2 additions & 5 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Passed: 269/1113
Passed: 272/1113

# All Passed:
* babel-plugin-transform-numeric-separator
Expand Down Expand Up @@ -825,7 +825,7 @@ Passed: 269/1113
* regression/11061/input.mjs
* variable-declaration/non-null-in-optional-chain/input.ts

# babel-plugin-transform-react-jsx (107/170)
# babel-plugin-transform-react-jsx (110/170)
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
* autoImport/after-polyfills-script-not-supported/input.js
* autoImport/auto-import-react-source-type-module/input.js
Expand All @@ -850,14 +850,12 @@ Passed: 269/1113
* react/optimisation.react.constant-elements/input.js
* react/should-add-quotes-es3/input.js
* react/should-allow-jsx-docs-comment-with-pragma/input.js
* react/should-allow-pragmafrag-and-frag/input.js
* react/should-disallow-spread-children/input.js
* react/should-disallow-valueless-key/input.js
* react/should-disallow-xml-namespacing/input.js
* react/should-throw-error-namespaces-if-not-flag/input.js
* react/should-warn-when-importSource-is-set/input.js
* react/should-warn-when-importSource-pragma-is-set/input.js
* react/weird-symbols/input.js
* react/wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js
* react/wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js
* react/wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js
Expand Down Expand Up @@ -885,7 +883,6 @@ Passed: 269/1113
* runtime/defaults-to-automatic/input.js
* runtime/defaults-to-classis-babel-7/input.js
* runtime/invalid-runtime/input.js
* runtime/pragma-runtime-classsic/input.js
* runtime/runtime-automatic/input.js
* spread-transform/transform-to-babel-extend/input.js
* spread-transform/transform-to-object-assign/input.js
Expand Down

0 comments on commit 28c0b85

Please sign in to comment.