G
Garrett said:
^^^^^^^^Thomas said:Garrett said:
| Host objects have no rules
|
| Next problem with DOM extension is that DOM objects are host objects,
| and host objects are the worst bunch. By specification (ECMA-262 3rd.
| ed), host objects are allowed to do things, no other objects can even
| dream of. To quote relevant section [8.6.2]:
|
| Host objects may implement these internal methods with any
| implementation-dependent behaviour, or it may be that a host object
| implements only some internal methods and not others.
|
| The internal methods specification talks about are [[Prototype]],
| [[Class]], [[Value]], [[Get]], [[Put]], etc. Note how it says that
| internal methods behavior is implementation-dependent.
The (unfortunately usual) lack of several proper English pronouns aside,
Thomas said:Garrett said:
| Host objects have no rules
|
| Next problem with DOM extension is that DOM objects are host objects, and
| host objects are the worst bunch. By specification (ECMA-262 3rd. ed),
| host objects are allowed to do things, no other objects can even dream
| of. To quote relevant section [8.6.2]:
|
| Host objects may implement these internal methods with any
| implementation-dependent behaviour, or it may be that a host object
| implements only some internal methods and not others.
|
| The internal methods specification talks about are [[Prototype]],
| [[Class]], [[Value]], [[Get]], [[Put]], etc. Note how it says that
| internal methods behavior is implementation-dependent.
The (unfortunately usual) lack of several proper English pronouns aside, it
is absolutely incorrect to refer to the [[Prototype]], [[Class]],
[[Value]], [[Get]], and [[Put]] properties as methods (of those, only
[[Get]] and [[Put]] are), and to make it look as if the quoted text from
the Specification referred to them while omitting the fact that
,-[ES3F, 8.6.2]
|
| [...]
| Every object (including host objects) must implement the [[Prototype]]
| and [[Class]] properties and the [[Get]], [[Put]], [[CanPut]],
| [[HasProperty]], [[Delete]], and [[DefaultValue]] methods.
In fact,
| For native objects the [[Get]], [[Put]], [[CanPut]], [[HasProperty]],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| [[Delete]] and [[DefaultValue]] methods behave as described in described
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| in sections 8.6.2.1, 8.6.2.2, 8.6.2.3, 8.6.2.4, 8.6.2.5 and 8.6.2.6,
| respectively, except that Array objects have a slightly different
| implementation of the [[Put]] method (section 15.4.5.1). Host objects may
| implement these methods in any manner unless specified otherwise; for
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| example, one possibility is that [[Get]] and [[Put]] for a particular
| host object indeed fetch and store property values but [[HasProperty]]
| always generates false."
meaning that host objects are _not_ free to implement the [[Prototype]] and
[[Class]] properties as they want.
The examples that follow
| document.createElement('p').offsetParent; // "Unspecified error."
| new ActiveXObject("MSXML2.XMLHTTP").send; // "Object doesn't support
| this property or method"
are particularly bogus (and multi-line pre-comments should be used instead
of single-line post-comments):
It is to be expected that a newly created element object would not provide
access to its `offsetParent' property as it has not been inserted into the
documented tree, and the value of its `offsetParent' property would not
make any sense at this point even if it had one. It is further to be
expected that a newly created XHR object would not allow access to its
`send' property before its `open' property had been called.
David said:It doesn't let you type convert it (or assign a reference to it) even
after - open - has been called. It's a method of an ActiveX object (and
implemented as a SafeArray object) and therefore type "unknown". All
you can do safely is call it or use the typeof operator to find out this
is the case.
Thomas said:In fact,
| For native objects the [[Get]], [[Put]], [[CanPut]], [[HasProperty]],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| [[Delete]] and [[DefaultValue]] methods behave as described in described
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| in sections 8.6.2.1, 8.6.2.2, 8.6.2.3, 8.6.2.4, 8.6.2.5 and 8.6.2.6,
| respectively, except that Array objects have a slightly different
| implementation of the [[Put]] method (section 15.4.5.1). Host objects may
| implement these methods in any manner unless specified otherwise; for
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The examples that follow
| document.createElement('p').offsetParent; // "Unspecified error."
| new ActiveXObject("MSXML2.XMLHTTP").send; // "Object doesn't support
| this property or method"
</nonsense>are particularly bogus (and multi-line pre-comments should be used instead
of single-line post-comments):
It is to be expected that a newly created element object would not provide
access to its `offsetParent' property as it has not been inserted into the
documented tree, and the value of its `offsetParent' property would not
make any sense at this point even if it had one.
It is further to be
expected that a newly created XHR object would not allow access to its
`send' property before its `open' property had been called.
Asen said:Thomas said:In fact,
| For native objects the [[Get]], [[Put]], [[CanPut]], [[HasProperty]],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| [[Delete]] and [[DefaultValue]] methods behave as described in
| [[described
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| in sections 8.6.2.1, 8.6.2.2, 8.6.2.3, 8.6.2.4, 8.6.2.5 and 8.6.2.6,
| respectively, except that Array objects have a slightly different
| implementation of the [[Put]] method (section 15.4.5.1). Host objects
| may implement these methods in any manner unless specified otherwise;
| for
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[[DefaultValue]] of Date objects without hint argument, call first
`toString' instead of `valueOf'. 8.6.2.6 [[DefaultValue]] (hint)
Relevance?
The examples that follow
| document.createElement('p').offsetParent; // "Unspecified error."
| new ActiveXObject("MSXML2.XMLHTTP").send; // "Object doesn't support
| this property or method"
<nonsense>
kangax said:The goal was to show examples of property access on host objects that
result in errors being thrown. Whether they are bogus or not doesn't
really matter here.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.