mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 03:01:48 +03:00
fix(es/react): Visit children nodes in jsx-src
pass (#8212)
**Related issue:** - Closes #8210
This commit is contained in:
parent
2b35e6c159
commit
47733a951c
25
crates/swc/tests/fixture/issues-8xxx/8210/input/.swcrc
Normal file
25
crates/swc/tests/fixture/issues-8xxx/8210/input/.swcrc
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"jsc": {
|
||||||
|
"parser": {
|
||||||
|
"syntax": "ecmascript",
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"target": "es2022",
|
||||||
|
"loose": false,
|
||||||
|
"minify": {
|
||||||
|
"compress": false,
|
||||||
|
"mangle": false
|
||||||
|
},
|
||||||
|
"transform": {
|
||||||
|
"react": {
|
||||||
|
"development": true,
|
||||||
|
"runtime": "automatic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"module": {
|
||||||
|
"type": "es6"
|
||||||
|
},
|
||||||
|
"minify": false,
|
||||||
|
"isModule": true
|
||||||
|
}
|
3
crates/swc/tests/fixture/issues-8xxx/8210/input/1.js
Normal file
3
crates/swc/tests/fixture/issues-8xxx/8210/input/1.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const Component = () => {
|
||||||
|
return (<p thing={<a />}>Hello</p>)
|
||||||
|
}
|
15
crates/swc/tests/fixture/issues-8xxx/8210/output/1.js
Normal file
15
crates/swc/tests/fixture/issues-8xxx/8210/output/1.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
||||||
|
const Component = ()=>{
|
||||||
|
return /*#__PURE__*/ _jsxDEV("p", {
|
||||||
|
thing: /*#__PURE__*/ _jsxDEV("a", {}, void 0, false, {
|
||||||
|
fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js",
|
||||||
|
lineNumber: 2,
|
||||||
|
columnNumber: 23
|
||||||
|
}, void 0),
|
||||||
|
children: "Hello"
|
||||||
|
}, void 0, false, {
|
||||||
|
fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js",
|
||||||
|
lineNumber: 2,
|
||||||
|
columnNumber: 13
|
||||||
|
}, this);
|
||||||
|
};
|
@ -2,7 +2,7 @@ use swc_common::{sync::Lrc, SourceMap, DUMMY_SP};
|
|||||||
use swc_ecma_ast::*;
|
use swc_ecma_ast::*;
|
||||||
use swc_ecma_transforms_base::perf::Parallel;
|
use swc_ecma_transforms_base::perf::Parallel;
|
||||||
use swc_ecma_utils::quote_ident;
|
use swc_ecma_utils::quote_ident;
|
||||||
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut};
|
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
@ -34,6 +34,8 @@ impl VisitMut for JsxSrc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.visit_mut_children_with(self);
|
||||||
|
|
||||||
let loc = self.cm.lookup_char_pos(e.span.lo);
|
let loc = self.cm.lookup_char_pos(e.span.lo);
|
||||||
let file_name = loc.file.name.to_string();
|
let file_name = loc.file.name.to_string();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user