Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jan 24, 2024
1 parent 4c97260 commit 010f659
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<const MINIFY: bool> Gen<MINIFY> for Directive {
// A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
// So here should print original `directive` value, the `expression` value is escaped str.
// See https://github.com/babel/babel/blob/main/packages/babel-generator/src/generators/base.ts#L64
print_origin_str(self.directive.as_str(), p);
p.print_str(self.directive.as_str().to_string().as_bytes());
p.print_semicolon();
}
}
Expand Down Expand Up @@ -1164,24 +1164,6 @@ fn print_str<const MINIFY: bool>(s: &str, p: &mut Codegen<{ MINIFY }>) {
p.print(quote as u8);
}

fn print_origin_str<const MINIFY: bool>(s: &str, p: &mut Codegen<{ MINIFY }>) {
p.print(b'\'');
for c in s.chars() {
match c {
// Allow `U+2028` and `U+2029` in string literals
// <https://tc39.es/proposal-json-superset>
// <https://github.com/tc39/proposal-json-superset>
LS => p.print_str(b"\\u2028"),
PS => p.print_str(b"\\u2029"),
'\u{a0}' => {
p.print_str(b"\\xA0");
}
_ => p.print_str(c.to_string().as_bytes()),
}
}
p.print(b'\'');
}

impl<const MINIFY: bool> Gen<MINIFY> for StringLiteral {
fn gen(&self, p: &mut Codegen<{ MINIFY }>, _ctx: Context) {
print_str(self.value.as_str(), p);
Expand Down

0 comments on commit 010f659

Please sign in to comment.