Skip to content

Commit

Permalink
Change StringGetOwnProperty to produce the same strings that the lexe…
Browse files Browse the repository at this point in the history
…r produces (#1460)
  • Loading branch information
raskad authored Aug 11, 2021
1 parent e698e5c commit e9093b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion boa/src/builtins/string/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ fn string_get_property() {
assert_eq!(forward(&mut context, "'abc'[2]"), "\"c\"");
assert_eq!(forward(&mut context, "'abc'[3]"), "undefined");
assert_eq!(forward(&mut context, "'abc'['foo']"), "undefined");
assert_eq!(forward(&mut context, "'😀'[0]"), "\"\\ud83d\"");
assert_eq!(forward(&mut context, "'😀'[0]"), "\"\"");
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions boa/src/object/internal_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ impl GcObject {
return None;
}

let result_str = string.encode_utf16().nth(pos).map(|utf16_val| {
char::from_u32(u32::from(utf16_val))
.map_or_else(|| Value::from(format!("\\u{:x}", utf16_val)), Value::from)
})?;
let result_str = string
.encode_utf16()
.nth(pos)
.map(|utf16_val| Value::from(String::from_utf16_lossy(&[utf16_val])))?;

let desc = PropertyDescriptor::builder()
.value(result_str)
Expand Down

0 comments on commit e9093b3

Please sign in to comment.