Why is this configurable property not deletable?

自古美人都是妖i 提交于 2019-11-29 07:02:42

Effectively, configurable properties are deletable.

But there is a big problem: that only applies to native objects, but not to host objects.

As explained in 8.6.2 - Object Internal Properties and Methods,

Host objects may support these internal properties with any implementation-dependent behaviour as long as it is consistent with the specific host object restrictions stated in this document.

For those, [[GetOwnProperty]] must behave differently:

If a property is described as a data property and it may return different values over time, then either or both of the [[Writable]] and [[Configurable]] attributes must be true even if no mechanism to change the value is exposed via the other internal methods.

In your example, form.elements is a HTMLFormControlsCollection instance defined by the HTML spec, so it's a host object.

Therefore, the situation is

  • It has a custom [[GetOwnProperty]] which says that the property '0' is configurable because its value may change.
  • It also has a custom [[Delete]] which doesn't delete the property, even if [[GetOwnProperty]] says it's configurable.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!