[thelist] Workaround for setAttribute bug in IE7?

Matt Warden mwarden at gmail.com
Tue Dec 12 18:37:47 CST 2006

On 12/12/06, Lee kowalkowski <lee.kowalkowski at googlemail.com> wrote:
> ...because you're invoking an assignment operator on a DOM object in
> the first place?  In JavaScript, the assignment operator often creates
> new properties: window.foo = "bar"; - If I thought that wasn't capable
> of creating foo if it didn't exist, I ought to read the ECMAScript
> language specification again.

Yes, it creates an *object property* in JavaScript. If you read my
entire message (not just the portion you replied to), you'll see I'm
saying that having an assignment with the side effect of creating DOM
nodes is a really dumb idea.

Question: does this create an attribute node or not?

domnode.length = 4;

Answer: Thanks to this horrible design decision, you don't know unless
you know what domnode is and whether .length is just an object
property or an object property tied to an attribute node in the DOM.

> None of the above in IE - you get an invalid argument exception.  Now
> it *is* a really dumb idea to expect assigning an property to null
> will delete the property!

Again, please read my message carefully. I am not talking about
properties, I'm talking about attribute nodes in the DOM. Assuming you
understand this, your argument is:

Great idea: assigning value to object property creates DOM attribute node
Really dumb idea: removing assignment to object property deletes DOM
attribute node


Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list