[thelist] Workaround for setAttribute bug in IE7?

Matt Warden mwarden at gmail.com
Thu Dec 14 07:26:48 CST 2006

On 12/14/06, Lee kowalkowski <lee.kowalkowski at googlemail.com> wrote:
> > And here is a real-world example:
> > http://mwarden.f2o.org/sandbox/attributetest.htm
> A cryptic example at best, there's no explanation to back up what
> you're trying to demonstrate.  No wonder I'm having difficulty
> understanding you.

Apologies. I unfortunately did not have a lot of time to explain what
I thought was obvious since the example includes nothing other than
the setAttribute issue I'm discussing. Writing up the example itself
was pushing it, but you were obviously having trouble with th
explanation and I thought an example would help.

The alternative to the setAttribute lines is:

input.type = 'text';
input.size = 5;

These could easily be object properties with no side effect on the
DOM, just like:

input.foo = "bar";

input.size = 5; creates an attribute node in the DOM. input.foo =
"bar"; does not. (As an aside, what if my doctype defines an attribute
called "foo"?)

Try to make this simple:

Clearly an operation manipulating the DOM:
input.setAttribute('size', 5);

Clearly an assignment to an object property:
input.size = 5;

Aside from my entire argument, you can do a simple google search to
see how often this issue trips up developers.

(If you want me to respond to the name-calling portion of your email,
perhaps we should take it offlist. Thanks.)

Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list