<op.tzqg9y2hidj3kv@hp-a0a83fcd39d2.palace.opera.no>
Current votes: None.
(This is part of my detailed review of the Document Object Model section=
.)
The spec doesn't say what UAs are to do with the [[Get]] method on the =
HTMLDocument interface. There are some interoperability problems. See:
http://simon.html5.org/test/html/dom/interfaces/HTMLDocument/Get-met=
hod/demos/
For reference I'll include my findings below:
-----------------8<-----------------
Firefox:
1. look for all _name elements_ element with the name=3D"" X.
2. if one element was found, return that and abort these steps.
3. otherwise if two or more elements were found, return a nodelist of th=
ose
elements and abort these steps.
4. otherwise, if document.getElementById(X) returns an _id element_
return that and abort these steps.
5. return undefined.
A _name element_ is applet, embed, form, img, object
An _id element_ is applet, embed, img, object
Safari:
1. look for all _name elements_ and _id elements_ with the name=3D"" or =
id=3D""
X, respectively.
2. if one element was found, return that and abort these steps.
3. otherwise if two or more elements were found, return an HTMLCollectio=
n
of those elements and abort these steps.
4. return undefined.
A _name element_ is applet, embed, form, iframe, img, object.
An _id element_ is applet, object.
object above means object that contains only whitespace and <param>s.
For iframes, return the element's contentWindow instead of the element.
IE:
It's hard to pin down what IE does. It seems to have special tokenizatio=
n =
rules for <object>. It's like a pseudo-CDATA element that knows about =
<param>s. Whether the <object> will be replaced with its contents (which=
=
will be parsed as HTML at that point) depends on how the <param> tags ar=
e =
placed and where whitespace occurs, and the phase of the moon. Anyway, i=
f =
it is to be replaced, it will be replaced after the load event has fired=
. =
See: http://krijnhoetmer.nl/irc-logs/whatwg/20071005#l-193
As an aside: it seems that setAttribute("name", "x") does nothing in IE =
on =
applet, embed, form, iframe, img, object, if the element didn't have a =
name=3D"" attribute before.
Whether it is replaced of course affects what [[Get]] returns, and when =
=
you call [[Get]] (before or after the load event).
Anyway.
1. look for all _name elements_ and _id elements_ with the name=3D"" or =
id=3D""
X, respectively.
2. if one element was found, return that and abort these steps.
3. otherwise if two or more elements were found, return a collection of
those elements and abort these steps.
4. return undefined.
A _name element_ is applet, embed, form, iframe, img, object.
An _id element_ is applet, object.
For iframes, return the element's contentWindow instead of the element.
Opera:
1. look for all _name elements_ and _id elements_ with the name=3D"" or =
id=3D""
X, respectively.
2. if one element was found, return that and abort these steps.
3. otherwise if two or more elements were found, return a collection of
those elements and abort these steps.
4. return undefined.
A _name element_ is applet, embed, form, iframe, img, object.
An _id element_ is applet, embed, form, iframe, img, object.
* * *
Now, as you might imagine, the biggest interoperability problem arises =
from the fact that IE does its crazy thing with replacing object elemen=
ts =
with their contents. In particular the following case:
<object id=3Dx><embed name=3Dx></object>
Scripts will assume that document.x returns an element and not an array.=
=
Opera will return an array. We can't do what IE does. So that leaves the=
=
Safari approach and the Firefox approach. Safari seems to be closer to I=
E.
----------------->8-----------------
I'd suggest to spec what Safari does, except s/whitespace and =
<param>s/comments, PIs, whitespace and <param>s/
Test cases for that: =
http://simon.html5.org/test/html/dom/interfaces/HTMLDocument/Get-method/=
-- =
Simon Pieters
Opera Software