mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 03:01:48 +03:00
0259a7465f
**Description:** This PR also updates `rkyv` to `=0.7.40`. **Related issue:** - Closes https://github.com/swc-project/swc/issues/6807.
41 lines
960 B
Rust
41 lines
960 B
Rust
use swc_ecma_ast::*;
|
|
use swc_ecma_parser::{EsConfig, Syntax};
|
|
use swc_ecma_transforms_testing::test_transform;
|
|
use swc_ecma_visit::Fold;
|
|
|
|
struct Panicking;
|
|
|
|
impl Fold for Panicking {
|
|
fn fold_jsx_opening_element(&mut self, node: JSXOpeningElement) -> JSXOpeningElement {
|
|
let JSXOpeningElement { name, .. } = &node;
|
|
println!("HMM");
|
|
|
|
if let JSXElementName::Ident(Ident { sym, .. }) = name {
|
|
panic!("visited: {}", sym)
|
|
}
|
|
|
|
node
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
#[should_panic = "visited"]
|
|
fn ensure_visited() {
|
|
test_transform(
|
|
Syntax::Es(EsConfig {
|
|
jsx: true,
|
|
..Default::default()
|
|
}),
|
|
|_| Panicking,
|
|
"
|
|
import React from 'react';
|
|
const comp = () => <amp-something className='something' />;
|
|
",
|
|
"
|
|
import React from 'react';
|
|
const comp = () => <amp-something className='something' />;
|
|
",
|
|
false,
|
|
);
|
|
}
|