From a705b0d275bc25110d20ab1e744f3f89fc982ba8 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 12 Aug 2022 10:46:17 -0700 Subject: [PATCH] Normative: allow host exotic objects to reject private fields (#2807) --- spec.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec.html b/spec.html index c7d7577458..59326860c1 100644 --- a/spec.html +++ b/spec.html @@ -6816,6 +6816,8 @@

+ 1. If the host is a web browser, then + 1. Perform ? HostEnsureCanAddPrivateElement(_O_). 1. Let _entry_ be PrivateElementFind(_O_, _P_). 1. If _entry_ is not ~empty~, throw a *TypeError* exception. 1. Append PrivateElement { [[Key]]: _P_, [[Kind]]: ~field~, [[Value]]: _value_ } to _O_.[[PrivateElements]]. @@ -6834,6 +6836,8 @@

1. Assert: _method_.[[Kind]] is either ~method~ or ~accessor~. + 1. If the host is a web browser, then + 1. Perform ? HostEnsureCanAddPrivateElement(_O_). 1. Let _entry_ be PrivateElementFind(_O_, _method_.[[Key]]). 1. If _entry_ is not ~empty~, throw a *TypeError* exception. 1. Append _method_ to _O_.[[PrivateElements]]. @@ -6844,6 +6848,25 @@

+ +

+ HostEnsureCanAddPrivateElement ( + _O_: an Object, + ): either a normal completion containing ~unused~ or a throw completion +

+
+
description
+
It allows host environments to prevent the addition of private elements to particular host-defined exotic objects.
+
+

An implementation of HostEnsureCanAddPrivateElement must conform to the following requirements:

+
    +
  • If _O_ is not a host-defined exotic object, this abstract operation must return NormalCompletion(~unused~) and perform no other steps.
  • +
  • Any two calls of this abstract operation with the same argument must return the same kind of Completion Record.
  • +
+

The default implementation of HostEnsureCanAddPrivateElement is to return NormalCompletion(~unused~).

+

This abstract operation is only invoked by ECMAScript hosts that are web browsers.

+
+

PrivateGet (