From 21ef83940e443d7bf6ddc47bb0ea0c16a02b9ced Mon Sep 17 00:00:00 2001 From: neeldug <5161147+neeldug@users.noreply.github.com> Date: Thu, 16 Sep 2021 15:19:55 +0100 Subject: [PATCH] missing normalization improvement for has (#1578) related to: #1445 --- boa/src/builtins/map/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/boa/src/builtins/map/mod.rs b/boa/src/builtins/map/mod.rs index 31a553dd6e..776b9c81a6 100644 --- a/boa/src/builtins/map/mod.rs +++ b/boa/src/builtins/map/mod.rs @@ -411,6 +411,19 @@ impl Map { ) -> JsResult { let key = args.get_or_undefined(0); + const JS_ZERO: &JsValue = &JsValue::Rational(0f64); + + let key = match key { + JsValue::Rational(r) => { + if r.is_zero() { + JS_ZERO + } else { + key + } + } + _ => key, + }; + // 1. Let M be the this value. if let JsValue::Object(ref object) = this { // 2. Perform ? RequireInternalSlot(M, [[MapData]]).