mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 14:16:12 +03:00
fix(es/react): Don't panic on key
without a value (#6945)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/6939.
This commit is contained in:
parent
4c6775646b
commit
14454c9dbd
@ -533,10 +533,18 @@ where
|
||||
.value
|
||||
.and_then(jsx_attr_value_to_expr)
|
||||
.map(|expr| expr.as_arg());
|
||||
assert_ne!(
|
||||
key, None,
|
||||
"value of property 'key' should not be empty"
|
||||
);
|
||||
|
||||
if key.is_none() {
|
||||
HANDLER.with(|handler| {
|
||||
handler
|
||||
.struct_span_err(
|
||||
i.span,
|
||||
"The value of property 'key' should not \
|
||||
be empty",
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
const test = <div key></div>
|
@ -0,0 +1 @@
|
||||
{ "runtime": "automatic" }
|
@ -0,0 +1,2 @@
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const test = /*#__PURE__*/ _jsx("div", {});
|
@ -0,0 +1,6 @@
|
||||
|
||||
x The value of property 'key' should not be empty
|
||||
,-[input.js:1:1]
|
||||
1 | const test = <div key></div>
|
||||
: ^^^
|
||||
`----
|
Loading…
Reference in New Issue
Block a user