Re: DOM dynamically built table and addEventListener....



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>
.



Relevant Pages

  • Re: Google Closure: Style Points
    ... And that javascript is very frequently very bad, ... However, that is immediate followed, within the same script element, ... to make a reference to the function a new property of the object that ... The first thing to point out about the above is that the 'compression' ...
    (comp.lang.javascript)
  • Re: OO javascript... this doesnt appear to point to the object
    ... aspects of JavaScript OOP (completely missed in 99.9% of relevant ... function myFunction() ... var myFunction= function; ... variable myFunction and then we are assigning a reference of that newly ...
    (comp.lang.javascript)
  • Re: Decoding html pages
    ... for the casual users via obfuscating javascript. ... It is easy to remove it from the HTML page (the DOM function, ... Here is what I have come up with to hide it from firebug. ... functions and Javascript variables) of the document one finds a reference ...
    (comp.lang.javascript)
  • Re: Augmenting functions
    ... I am reading Javascript the good parts and came across this that I ... it is expected to be a reference to a function). ... Crockford wants all such objects to inherit the method function. ... Quite a few of the built-in objects in javascript are set up this ...
    (comp.lang.javascript)
  • Re: FAQ Topic - What are object models? (2009-03-01)
    ... The most commonly used object models via javascript are ... The term "Host object" comes up frequently in answers to questions or problems that arise from those who are less aware of the difference between Host object and Native object. ... Explains about ECMAScript and host objects in DOM, also brief mention of other environments ASP, WSH, etc. ...
    (comp.lang.javascript)

Loading