mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 12:49:21 +03:00
fix(es/react): Fix handling of whitespaces (#6935)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/6931.
This commit is contained in:
parent
5a598140c1
commit
a9b25aaf4a
@ -1336,15 +1336,19 @@ fn count_children(children: &[JSXElementChild]) -> usize {
|
||||
fn transform_jsx_attr_str(v: &str) -> String {
|
||||
let single_quote = false;
|
||||
let mut buf = String::with_capacity(v.len());
|
||||
let mut iter = v.chars().peekable();
|
||||
|
||||
for c in v.chars() {
|
||||
while let Some(c) = iter.next() {
|
||||
match c {
|
||||
'\u{0008}' => buf.push_str("\\b"),
|
||||
'\u{000c}' => buf.push_str("\\f"),
|
||||
' ' | '\n' | '\r' | '\t' => {
|
||||
if buf.ends_with(' ') {
|
||||
} else {
|
||||
buf.push(' ')
|
||||
' ' => buf.push(' '),
|
||||
|
||||
'\n' | '\r' | '\t' => {
|
||||
buf.push(' ');
|
||||
|
||||
while let Some(' ') = iter.peek() {
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
'\u{000b}' => buf.push_str("\\v"),
|
||||
|
@ -0,0 +1,2 @@
|
||||
const f1 = <Component on={" "} />
|
||||
const f2 = <Component on=" " />
|
@ -0,0 +1,6 @@
|
||||
const f1 = /*#__PURE__*/ React.createElement(Component, {
|
||||
on: " "
|
||||
});
|
||||
const f2 = /*#__PURE__*/ React.createElement(Component, {
|
||||
on: " "
|
||||
});
|
Loading…
Reference in New Issue
Block a user