W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2010

[whatwg] getElementById

From: Perry Smith <pedzsan@gmail.com>
Date: Mon, 10 May 2010 13:10:45 -0500
Message-ID: <E7E377A2-96CA-4B67-A2C8-39D9C2E995BC@gmail.com>
I see places that explicitly state that the same object is returned on some operations.  For example, the element.style has that clause.

I have not found in either html5 or the DOM documentation that is referenced an explicit statement to this effect for getElementById.

In FF 3.5, it seems to be true but it would be nice to know if it is or is not something that can be depended upon.

The other part to this that is not explicitly mentioned is if I attach a new javascript attribute to the object, is that legal?  Is it defined to work?  I have not found a statement one way or the other.


foo = getElementById('foo');
foo.newAttr = true;

/* later */

foo = getElementById('foo');
if (foo.newAttr) {
  alert("happy happy joy joy");

Thank you,
Received on Monday, 10 May 2010 11:10:45 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:23 UTC