fix(es/codegen): Don't strip necessary escape characters (#7687)

**Related issue:**

 - Closes #7678.
This commit is contained in:
Donny/강동윤 2023-08-08 07:17:59 +09:00 committed by GitHub
parent 0219eebeb9
commit b45649b8d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 1 deletions

View 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
}

View File

@ -0,0 +1,5 @@
let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
let obj = {
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
};

View File

@ -0,0 +1 @@
let str="\uD83D\uDC68\\u200D\uD83D\uDE80";let obj={"\uD83D\uDC68\\u200D\uD83D\uDE80":"wrong"};

View File

@ -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('\\');
}
}
_ => {

View File

@ -0,0 +1,5 @@
export let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
export let obj = {
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
};

View File

@ -0,0 +1,4 @@
export let str = "\\uD83D\\uDC68\\u200D\\uD83D\\uDE80";
export let obj = {
"\\uD83D\\uDC68\\u200D\\uD83D\\uDE80": "wrong"
};