Skip to content

Commit 257bc30

Browse files
authored
fix(engine): return null from IsHTMLDDA [[Call]] per Annex B §B.3.6.1 (#5511)
<!--- Thank you for contributing to Boa! Please fill out the template below, and remove or add any information as you feel necessary. ---> This Pull Request fixes the return value of `IsHTMLDDA`'s `[[Call]]` internal method. According to ECMAScript Annex B §B.3.6.1 and test262's `INTERPRETING.md`, objects with the `[[IsHTMLDDA]]` internal slot (such as `$262.IsHTMLDDA` and `document.all`) must return `null` when called with no arguments or with an empty string. It changes the following: - Change `is_html_dda_call` in `core/engine/src/builtins/is_html_dda.rs` to return `JsValue::null()` instead of `JsValue::undefined()`. - Update doc comments to cite Annex B §B.3.6.1. - Resolves all 6 failing test262 tests in `test/annexB/built-ins/String/prototype/` (`replace`, `replaceAll`, `match`, `matchAll`, `split`, `search` `custom-*-emulates-undefined.js`), bringing the suite to 100% conformance (111/111 passed).
1 parent 4b61183 commit 257bc30

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core/engine/src/builtins/is_html_dda.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727
/// This is used by the `$262.IsHTMLDDA` test harness object and models the
2828
/// legacy `document.all` behavior per ECMAScript Annex B §B.3.6.
2929
///
30-
/// The object is callable — when called, it returns `undefined`.
30+
/// The object is callable — when called, it returns `null` per ECMAScript Annex B §B.3.6.1.
3131
#[derive(Debug, Clone, Copy, Trace, Finalize)]
3232
#[boa_gc(empty_trace)]
3333
pub struct IsHTMLDDA;
@@ -44,7 +44,7 @@ impl JsData for IsHTMLDDA {
4444

4545
/// The `[[Call]]` internal method for `IsHTMLDDA` objects.
4646
///
47-
/// When called, simply returns `undefined`.
47+
/// When called, simply returns `null` per ECMAScript Annex B §B.3.6.1.
4848
#[allow(clippy::unnecessary_wraps)]
4949
fn is_html_dda_call(
5050
_obj: &JsObject,
@@ -59,8 +59,8 @@ fn is_html_dda_call(
5959
let _func = context.vm.stack.pop();
6060
let _this = context.vm.stack.pop();
6161

62-
// Push undefined as the return value.
63-
context.vm.stack.push(JsValue::undefined());
62+
// Push null as the return value.
63+
context.vm.stack.push(JsValue::null());
6464

6565
Ok(CallValue::Complete)
6666
}

0 commit comments

Comments
 (0)