- From: ExE Boss <notifications@github.com>
- Date: Sat, 05 Sep 2020 03:53:18 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/issues/916@github.com>
The following snippet demonstrates the issue:
```webidl
[Exposed=Window]
interface Foo {
[Replaceable, LegacyLenientThis] readonly attribute any attr;
};
```
```js
Object.getOwnPropertyDescriptor(Foo, 'attr').set.call(123);
```
## Expected behaviour:
Either throw a `TypeError` or return `undefined`.
## Actual behaviour:
Because of **Step 4.5.5.1** in [attribute setter][dfn-attribute-setter]:
> 1. Let <var>esValue</var> be the **this** value, if it is not **null** or **undefined**, or <var>realm</var>’s [global object][concept-realm-global] otherwise. (This will subsequently cause a <code>[TypeError]</code> in a few steps, if the global object does not implement target and <code>\[[LegacyLenientThis]\]</code> is not specified.)
> 2. If <var>esValue</var> [is a platform object][is-a-platform-object], then [perform a security check][dfn-perform-a-security-check], passing <var>esValue</var>, <var>id</var>, and "setter".
> 3. Let <var>validThis</var> be **true** if <var>esValue</var> [implements] <var>target</var>, or **false** otherwise.
> 4. If <var>validThis</var> is **false** and <var>attribute</var> was not specified with the <code>\[[LegacyLenientThis]\]</code> [extended attribute][dfn-extended-attribute], then [throw] a <code>[TypeError]</code>.
> 5. If <var>attribute</var> is declared with the <code>\[[Replaceable]\]</code> extended attribute, then:<ol><li>Perform [?] [CreateDataProperty]\(<var>esValue</var>, <var>id</var>, <var>V</var>\).</li><li>Return **undefined**.</li></ol>
> 6. If <var>validThis</var> is **false**, then return **undefined**.
[CreateDataProperty] gets called unconditionally on the passed <var>esValue</var>, but <var>esValue</var> may contain a primitive value if <code>\[[LegacyLenientThis]\]</code> was also specified, which causes an [Assert] failure in **Step 1** of [CreateDataProperty].
[?]: https://tc39.github.io/ecma262/#sec-returnifabrupt-shorthands
[Assert]: https://tc39.es/ecma262/#assert
[CreateDataProperty]: https://tc39.github.io/ecma262/#sec-createdataproperty
[LegacyLenientThis]: https://heycam.github.io/webidl/#LegacyLenientThis
[Replaceable]: https://heycam.github.io/webidl/#Replaceable
[TypeError]: https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror
[concept-realm-global]: https://html.spec.whatwg.org/multipage/webappapis.html#concept-realm-global
[dfn-attribute-setter]: https://heycam.github.io/webidl/#dfn-attribute-setter
[dfn-extended-attribute]: https://heycam.github.io/webidl/#dfn-extended-attribute
[dfn-perform-a-security-check]: https://heycam.github.io/webidl/#dfn-perform-a-security-check
[implements]: https://heycam.github.io/webidl/#implements
[is-a-platform-object]: https://heycam.github.io/webidl/#is-a-platform-object
[throw]: https://heycam.github.io/webidl/#ecmascript-throw
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/916
Received on Saturday, 5 September 2020 10:53:31 UTC