From: David Mark on
Out of curiosity about Microsoft's newfound understanding of
attributes, I put together a set of tests. Two sets, actually:-

http://www.cinsoft.net/attributes.html

One calls get/removeAttribute methods assuming they work consistently
across all browsers (a common strategy). Results are almost exactly
as expected. All green in modern standards-based browsers tested
(e.g. Chrome, FF3.5.) Mostly green in IE8 standards mode (yes,
they've _still_ got some mistakes in there). Put IE8 in
"compatibility view" and all hell breaks loose (all but three tests
fail).

Out of further curiosity, I added a second set of the same tests using
wrapper functions and a feature test proposed here two years ago. All
is exactly the same, except that now IE8 compatibility mode passes all
but one test (enctype). I believe IE6/7 will pass all of them as
there is a workaround in there for that attribute.

The moral is to avoid these methods whenever possible (virtually
always). Calling them outside of a suitable wrapper is surefire
disaster as users can affect the behavior of these methods with a
toolbar button in IE8 (and what a silly button that is).

When might these methods be handy? CSS selector queries (if you find
them useful), parsing/serializing markup and XML elements (e.g SVG)
come to mind. Not a lot else.

But in the "real world", virtually every jQuery example uses its attr
method, which calls get/setAttribute, etc. The big problem is that
the people reading (and writing) these examples are taking it on blind
faith that the jQuery authors understand these issues (they clearly do
not). Maybe a nice picture will finally drive the point home. :)
From: David Mark on
On Nov 15, 11:34 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
> Out of curiosity about Microsoft's newfound understanding of
> attributes, I put together a set of tests.  Two sets, actually:-

[...]

Added a test for the broken IE8 attribute features (a test for one
anyway, with another workaround inferred). Of course, there may be
more (it was well into the century before all of the IE6/7 quirks
surfaced).
From: RobG on
On Nov 16, 2:34 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
> Out of curiosity about Microsoft's newfound understanding of
> attributes, I put together a set of tests.  Two sets, actually:-
>
> http://www.cinsoft.net/attributes.html
>
> One calls get/removeAttribute methods assuming they work consistently
> across all browsers (a common strategy).  Results are almost exactly
> as expected.  All green in modern standards-based browsers tested
> (e.g. Chrome, FF3.5.)  Mostly green in IE8 standards mode (yes,
> they've _still_ got some mistakes in there).  Put IE8 in
> "compatibility view" and all hell breaks loose (all but three tests
> fail).

If "compatible" means has the same number of failures, then yes, it's
compatible with my IE 6.

>
> Out of further curiosity, I added a second set of the same tests using
> wrapper functions and a feature test proposed here two years ago.  All
> is exactly the same, except that now IE8 compatibility mode passes all
> but one test (enctype).  I believe IE6/7 will pass all of them as
> there is a workaround in there for that attribute.

Nope, enctype still fails in IE 6. Will look into it further later.


--
Rob
From: David Mark on
On Nov 16, 2:09 am, RobG <rg...(a)iinet.net.au> wrote:
> On Nov 16, 2:34 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> > Out of curiosity about Microsoft's newfound understanding of
> > attributes, I put together a set of tests.  Two sets, actually:-
>
> >http://www.cinsoft.net/attributes.html
>
> > One calls get/removeAttribute methods assuming they work consistently
> > across all browsers (a common strategy).  Results are almost exactly
> > as expected.  All green in modern standards-based browsers tested
> > (e.g. Chrome, FF3.5.)  Mostly green in IE8 standards mode (yes,
> > they've _still_ got some mistakes in there).  Put IE8 in
> > "compatibility view" and all hell breaks loose (all but three tests
> > fail).
>
> If "compatible" means has the same number of failures, then yes, it's
> compatible with my IE 6.

IIRC, 6 and 7 won't match exactly. May not have enough tests in there
to show that.

>
>
>
> > Out of further curiosity, I added a second set of the same tests using
> > wrapper functions and a feature test proposed here two years ago.  All
> > is exactly the same, except that now IE8 compatibility mode passes all
> > but one test (enctype).  I believe IE6/7 will pass all of them as
> > there is a workaround in there for that attribute.
>
> Nope, enctype still fails in IE 6. Will look into it further later.

D'oh! That one is really screwy. The attributes collection key is
actually 'encType' (though that is not the DOM property name and IIRC
that property is missing in IE6/7), but the specified flag is never
set. Apparently it doesn't show up in outerHTML either. Whatever.

I added a few more tests. Didn't budge the success tally for IE6/7/
compatibility mode. Of course, that doesn't matter unless you rely on
these methods to be consistent from one IE version (or mode) to the
next. :)

There are certainly lots of related tests that will pass. More than
will fail certainly, which explains a lot about how "major" libraries
could waste years working around these headaches, even as IE8 is
tested and launched with what amounts to a destruct button. You can
see in the test suites that evidence was gathered, but apparently
nobody spotted the pattern (which was mostly documented around the
turn of the century).
From: David Mark on
On Nov 16, 2:09 am, RobG <rg...(a)iinet.net.au> wrote:
> On Nov 16, 2:34 pm, David Mark <dmark.cins...(a)gmail.com> wrote:
>
> > Out of curiosity about Microsoft's newfound understanding of
> > attributes, I put together a set of tests.  Two sets, actually:-
>
> >http://www.cinsoft.net/attributes.html
>
> > One calls get/removeAttribute methods assuming they work consistently
> > across all browsers (a common strategy).  Results are almost exactly
> > as expected.  All green in modern standards-based browsers tested
> > (e.g. Chrome, FF3.5.)  Mostly green in IE8 standards mode (yes,
> > they've _still_ got some mistakes in there).  Put IE8 in
> > "compatibility view" and all hell breaks loose (all but three tests
> > fail).
>
> If "compatible" means has the same number of failures, then yes, it's
> compatible with my IE 6.
>
>
>
> > Out of further curiosity, I added a second set of the same tests using
> > wrapper functions and a feature test proposed here two years ago.  All
> > is exactly the same, except that now IE8 compatibility mode passes all
> > but one test (enctype).  I believe IE6/7 will pass all of them as
> > there is a workaround in there for that attribute.
>
> Nope, enctype still fails in IE 6. Will look into it further later.

Turns out only for the default enctype. The MSHTML parser ignores it
as superfluous. So that one is just a harmless irritation. Several
other mistakes in IE8 standards mode are not.