Re: DOM dynamically built table and addEventListener....
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Mon, 02 Jun 2008 23:26:40 +0200
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
[Trying to augment host objects] can cause your Web application to
break. Silently, or with an error message. Anywhere, anytime.
But, for example :
var y= function (p) { return document.createElement(p) },
This as it is does not make much sense. See our recent discussion about the
viability of Prototype.js's $() method.
e= y('tag');
e.property= "whatever";
Is e a "host object" ?
`e' is *a reference to* a host object then (probably an object that
implements an element-related interface of W3C DOM Level 2 HTML).
In ECMAScript implementations, you can only work with references to objects,
never with objects directly.
Or you mean :
(y('tag')).property= "whatever";
??
You could also write
y('tag').property = "whatever";
or
[{foo: y('tag')}][0]["foo"].property = "whatever";
and so on with the same (here: possibly disastrous) outcome. How you
construct the reference to an object makes no difference regarding the
kind of object you are referring to.
However, your second variant adds further error-proneness as y() may not
return an object reference or a primitive value convertible to an object in
which case the property lookup would then result in a TypeError (exception).
With the first variant you can at least do feature-testing on the return
value and perhaps also on the property before you attempt to assign to the
property of the object; that would generally seem to be a wise course of
action, with the exception of universally supported properties of native
objects.
Please trim your quotes.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@xxxxxxxxxxxxxxxx>
.
- Follow-Ups:
- References:
- DOM dynamically built table and addEventListener....
- From: Quarco
- Re: DOM dynamically built table and addEventListener....
- From: Jorge
- Re: DOM dynamically built table and addEventListener....
- From: Thomas 'PointedEars' Lahn
- Re: DOM dynamically built table and addEventListener....
- From: Jorge
- Re: DOM dynamically built table and addEventListener....
- From: Thomas 'PointedEars' Lahn
- Re: DOM dynamically built table and addEventListener....
- From: Jorge
- DOM dynamically built table and addEventListener....
- Prev by Date: Re: document.lastModified help
- Next by Date: FAQ Topic - Why was my post not answered? (2008-06-03)
- Previous by thread: Re: DOM dynamically built table and addEventListener....
- Next by thread: Re: DOM dynamically built table and addEventListener....
- Index(es):
Relevant Pages
|
Loading