mirror of
https://github.com/swc-project/swc.git
synced 2024-12-29 00:23:10 +03:00
fix(es/codegen): Don't strip necessary escape characters (#7687)
**Related issue:** - Closes #7678.
This commit is contained in:
parent
0219eebeb9
commit
b45649b8d6
19
crates/swc/tests/fixture/issues-7xxx/7678/input/.swcrc
Normal file
19
crates/swc/tests/fixture/issues-7xxx/7678/input/.swcrc
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false
|
||||
},
|
||||
"target": "es2015",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
},
|
||||
"minify": true,
|
||||
"isModule": false
|
||||
}
|
5
crates/swc/tests/fixture/issues-7xxx/7678/input/1.js
Normal file
5
crates/swc/tests/fixture/issues-7xxx/7678/input/1.js
Normal file
@ -0,0 +1,5 @@
|
||||
let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
|
||||
|
||||
let obj = {
|
||||
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
|
||||
};
|
1
crates/swc/tests/fixture/issues-7xxx/7678/output/1.js
Normal file
1
crates/swc/tests/fixture/issues-7xxx/7678/output/1.js
Normal file
@ -0,0 +1 @@
|
||||
let str="\uD83D\uDC68\\u200D\uD83D\uDE80";let obj={"\uD83D\uDC68\\u200D\uD83D\uDE80":"wrong"};
|
@ -3770,6 +3770,8 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String {
|
||||
|
||||
inner_iter.next();
|
||||
next = inner_iter.peek();
|
||||
} else if next != Some(&'D') && next != Some(&'d') {
|
||||
buf.push('\\');
|
||||
}
|
||||
|
||||
if let Some(c @ 'D' | c @ 'd') = next {
|
||||
@ -3816,8 +3818,10 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String {
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if is_curly {
|
||||
buf.push_str("\\\\");
|
||||
} else {
|
||||
buf.push('\\');
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
@ -0,0 +1,5 @@
|
||||
export let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
|
||||
|
||||
export let obj = {
|
||||
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
|
||||
};
|
@ -0,0 +1,4 @@
|
||||
export let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
|
||||
export let obj = {
|
||||
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
|
||||
};
|
Loading…
Reference in New Issue
Block a user