Index of /test/html/dom/interfaces/HTMLDocument/Get-method/demos

      Name                    Last modified      Size  Description
Parent Directory - 001.htm 2007-10-04 07:52 1.5K name="": [[Get]] method on HTMLDocument (createElement) 002.htm 2007-10-04 07:52 1.5K id="": [[Get]] method on HTMLDocument (createElement) 003.htm 2007-10-04 07:52 1.3K name="": [[Get]] method on HTMLDocument (innerHTML) 004.htm 2007-10-04 07:52 1.3K id="": [[Get]] method on HTMLDocument (innerHTML) 005.htm 2007-10-04 07:52 880 multiple elements id="" 006.htm 2007-10-04 07:52 884 multiple elements name="" 007.htm 2007-10-04 07:52 207 two <object id=x> 008.htm 2007-10-04 07:52 213 two <object name=x> 009.htm 2007-10-04 07:52 235 <object id=x></object><object name=x> 010.htm 2007-10-04 09:02 267 <object name=x><embed name=x></object> 011.htm 2007-10-04 10:46 153 <object name=x>x</object>
HTML5 doesn't define what the [[Get]] method on HTMLDocument does. As you
might imagine, there are interoperability problems.


Firefox:

1. look for all _name elements_ element with the name="" 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 those
   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="" or id=""
   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 HTMLCollection
   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 tokenization
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 are
placed and where whitespace occurs, and the phase of the moon. Anyway, if
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="" 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="" or id=""
   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="" or id=""
   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 elements with
their contents. In particular the following case:

   <object id=x><embed name=x></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 IE.