Discussion:
Early feedback on header association algorithm
Aaron Leventhal
2008-10-29 17:43:21 UTC
Permalink
1. On this part:
"If there is a header cell in the table
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#concept-table>
whose corresponding |th
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#the-th-element>|
element has an ID that is equal to the value of id, then assign the
first such header cell in tree order to the data cell. "
I don't want to implement a special local table only
getElementByIdInTable. I'd rather have this reworded to something like
"If there is an element in the document with a corresponding ID (via
getElementById) equal to the value of /id/, and it is a header cell in
the current table, then assign it to the data cell."

2. The larger part of algorithm is upside down for our needs. I see a
use case for providing what headers are associated with a cell, but not
the other way around. Typically an AT will want to know what labels or
headers to present to a user when a user navigates to a cell. Therefore,
I wish the entire algorithm was flipped and tells us what headers are a
match for a given cell.

3. The one piece of information we do need when we are on a given <th>
is whether to expose it with ROLE_ROWHEADER or ROLE_COLUMNHEADER in our
GetRole() implementation. If scope isn't "row", "rowgroup", "col" or
"colgroup" then we'll need to base that on the position in the table. It
seems fairly obvious if the <th> is in an edge (but not corner)
position, but other cases are less obvious.

I haven't gone through the algorithm in fine detail yet, mostly because
of comment #2. We'd have to turn the algorithm inside out in order to
evaluate it.

- Aaronj
Kristof Zelechovski
2008-10-29 18:46:54 UTC
Permalink
The problem of table header identifiers is a reflection a general problem of
locality in markup: you cannot use templates without renaming the
identifiers, which is the easy part, and replacing the internal references
to the identifiers, which is the hard part. If you find this remark silly
because a solution is well-known, please forgive my illiterate comment
above; in that case, that solution should be applied.
Chris

-----Original Message-----
From: whatwg-bounces-***@public.gmane.org
[mailto:whatwg-bounces-***@public.gmane.org] On Behalf Of Aaron Leventhal
Sent: Wednesday, October 29, 2008 6:43 PM
To: WHATWG List
Subject: [whatwg] Early feedback on header association algorithm

1. On this part:
"If there is a header cell in the table
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.ht
ml#concept-table>
whose corresponding |th
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.ht
ml#the-th-element>|
element has an ID that is equal to the value of id, then assign the
first such header cell in tree order to the data cell. "
I don't want to implement a special local table only
getElementByIdInTable. I'd rather have this reworded to something like
"If there is an element in the document with a corresponding ID (via
getElementById) equal to the value of /id/, and it is a header cell in
the current table, then assign it to the data cell."

2. The larger part of algorithm is upside down for our needs. I see a
use case for providing what headers are associated with a cell, but not
the other way around. Typically an AT will want to know what labels or
headers to present to a user when a user navigates to a cell. Therefore,
I wish the entire algorithm was flipped and tells us what headers are a
match for a given cell.

3. The one piece of information we do need when we are on a given <th>
is whether to expose it with ROLE_ROWHEADER or ROLE_COLUMNHEADER in our
GetRole() implementation. If scope isn't "row", "rowgroup", "col" or
"colgroup" then we'll need to base that on the position in the table. It
seems fairly obvious if the <th> is in an edge (but not corner)
position, but other cases are less obvious.

I haven't gone through the algorithm in fine detail yet, mostly because
of comment #2. We'd have to turn the algorithm inside out in order to
evaluate it.

- Aaronj
Ian Hickson
2008-10-29 19:16:20 UTC
Permalink
Post by Kristof Zelechovski
The problem of table header identifiers is a reflection a general
problem of locality in markup: you cannot use templates without renaming
the identifiers, which is the easy part, and replacing the internal
references to the identifiers, which is the hard part. If you find this
remark silly because a solution is well-known, please forgive my
illiterate comment above; in that case, that solution should be applied.
Could I ask you to phrase your feedback in terms of changes you would like
to see to the spec, ideally with examples? People have told me (and I
concurr) that they have trouble following your feedback. (It is especially
hard since you don't quote context.)
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Kristof Zelechovski
2008-10-29 20:49:34 UTC
Permalink
I shall try to explain the general problem in more detail.
Suppose you have a template that inserts a table T into the Web page, and
some elements in the table have identifiers. It is not a safe operation
because the identifiers can conflict with element identifiers on the
containing page, or element identifiers within code snippets submitted to
the template as arguments. In order to preserve uniqueness of identifiers,
you can either rename them or use GUIDs. The first operation is tricky if
the identifiers are referred to by other attributes and scripts; the other
is unintuitive and seems like an overshoot (because what you need are
page-unique identfiers, not globally unique identifiers).
If I had a solution to this problem, I would be happy to submit it. I was
hoping for someone smarter than me to stand up and say "Oh, this is easy."
I also think this problem is not restricted to HTML, all markup languages
are affected.
My generic solution would be to add a global attribute named "local-id" and
add a method "HTMLElement.getChildById(arg)" to return the nearest (in terms
of the least depth) child of the element with the local-id equal to arg, or
the element itself. (This is the reverse of syntactic scoping). Elements
that have properties containing referring to other identifiers could locate
the referenced elements by local identifiers from the perspective of a
well-defined ancestor (FORM for LABEL, TABLE for TD, etc.) But I am far
from being sure that it is the right thing to require and that it would
solve a significant class of problems in a satisfactory way.
Bonus example:
<P id=PA local-id=a >...</P >
<TABLE ID=T
<THEAD ><TR ><TH id=TA local-id=a >...
<TBODY ><TR ><TD some-property-that-refers-to-an-id="a" ></TABLE >
Now T.getChildById("a") === TA.
Chris

-----Original Message-----
From: whatwg-bounces-***@public.gmane.org
[mailto:whatwg-bounces-***@public.gmane.org] On Behalf Of Ian Hickson
Sent: Wednesday, October 29, 2008 8:16 PM
To: Kristof Zelechovski
Cc: 'WHATWG List'
Subject: Re: [whatwg] Early feedback on header association algorithm
The problem of table header identifiers is a reflection a general
problem of locality in markup: you cannot use templates without renaming
the identifiers, which is the easy part, and replacing the internal
references to the identifiers, which is the hard part. If you find this
remark silly because a solution is well-known, please forgive my
illiterate comment above; in that case, that solution should be applied.
Could I ask you to phrase your feedback in terms of changes you would like
to see to the spec, ideally with examples? People have told me (and I
concurr) that they have trouble following your feedback. (It is especially
hard since you don't quote context.)
Ian Hickson
2008-10-29 21:54:46 UTC
Permalink
I shall try to explain the general problem in more detail. Suppose you
have a template that inserts a table T into the Web page, and some
elements in the table have identifiers. It is not a safe operation
because the identifiers can conflict with element identifiers on the
containing page, or element identifiers within code snippets submitted
to the template as arguments. In order to preserve uniqueness of
identifiers, you can either rename them or use GUIDs.
Just prefix them with the name of the template.

In general, this feedback seems unrelated to the header association
algorithm. Could I ask you to send feedback like this in new threads
instead of replying to tangentially related e-mails?

Cheers,
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Henri Sivonen
2008-11-22 13:50:21 UTC
Permalink
"If there is a header cell in the table <http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#concept-table
whose corresponding |th <http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#the-th-element
| element has an ID that is equal to the value of id, then assign
the first such header cell in tree order to the data cell. "
I don't want to implement a special local table only
getElementByIdInTable. I'd rather have this reworded to something like
"If there is an element in the document with a corresponding ID (via
getElementById) equal to the value of /id/, and it is a header cell
in the current table, then assign it to the data cell."
While implementing a special lookup method is something that one would
want to avoid, using getElementById has two problems:

1) It makes the association brittle under copy and paste. Consider a
case where a page author creates a table with internal id references
and then a maintainer duplicates the table and edits the contents of
the copy table. Now the table coming later in the document order is
inaccessible but this brokenness is unobvious to a person who isn't
accessing the page with AT.

2) It makes the reporting of table relationships not form a coherent
table. Consider a program that instead of allowing the user to
traverse the table an arc at a time tries to pull all the arcs from
the accessibility API and reconstruct the table in its own process
space. If there are arcs between tables, the result is not a table
structure at all.
--
Henri Sivonen
hsivonen-***@public.gmane.org
http://hsivonen.iki.fi/
Henri Sivonen
2008-11-22 14:06:41 UTC
Permalink
Post by Henri Sivonen
"If there is a header cell in the table <http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#concept-table
whose corresponding |th <http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#the-th-element
| element has an ID that is equal to the value of id, then assign
the first such header cell in tree order to the data cell. "
I don't want to implement a special local table only
getElementByIdInTable. I'd rather have this reworded to something like
"If there is an element in the document with a corresponding ID
(via getElementById) equal to the value of /id/, and it is a header
cell in the current table, then assign it to the data cell."
While implementing a special lookup method is something that one
1) It makes the association brittle under copy and paste. Consider a
case where a page author creates a table with internal id references
and then a maintainer duplicates the table and edits the contents of
the copy table. Now the table coming later in the document order is
inaccessible but this brokenness is unobvious to a person who isn't
accessing the page with AT.
2) It makes the reporting of table relationships not form a coherent
table. Consider a program that instead of allowing the user to
traverse the table an arc at a time tries to pull all the arcs from
the accessibility API and reconstruct the table in its own process
space. If there are arcs between tables, the result is not a table
structure at all.
Oops. I didn't read the text I quoted properly. Sorry. #2 was already
dealt with.

However, wouldn't testing if the cell is in the current table already
go a long way towards the complexity of implementing
getElementByIdInTable?
--
Henri Sivonen
hsivonen-***@public.gmane.org
http://hsivonen.iki.fi/
Aaron Leventhal
2008-12-02 08:39:06 UTC
Permalink
Maybe there is a deeper problem if copy & paste doesn't work right
because of IDs?

Or maybe there should be a node.getDescendantById() method?

I don't know. It just seems odd to implement something special here for
that.

- Aaron
Post by Henri Sivonen
Post by Henri Sivonen
Post by Aaron Leventhal
"If there is a header cell in the table
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#concept-table>
whose corresponding |th
<http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#the-th-element>|
element has an ID that is equal to the value of id, then assign the
first such header cell in tree order to the data cell. "
I don't want to implement a special local table only
getElementByIdInTable. I'd rather have this reworded to something like
"If there is an element in the document with a corresponding ID (via
getElementById) equal to the value of /id/, and it is a header cell
in the current table, then assign it to the data cell."
While implementing a special lookup method is something that one
1) It makes the association brittle under copy and paste. Consider a
case where a page author creates a table with internal id references
and then a maintainer duplicates the table and edits the contents of
the copy table. Now the table coming later in the document order is
inaccessible but this brokenness is unobvious to a person who isn't
accessing the page with AT.
2) It makes the reporting of table relationships not form a coherent
table. Consider a program that instead of allowing the user to
traverse the table an arc at a time tries to pull all the arcs from
the accessibility API and reconstruct the table in its own process
space. If there are arcs between tables, the result is not a table
structure at all.
Oops. I didn't read the text I quoted properly. Sorry. #2 was already
dealt with.
However, wouldn't testing if the cell is in the current table already
go a long way towards the complexity of implementing
getElementByIdInTable?
timeless
2008-12-02 15:07:30 UTC
Permalink
Maybe there is a deeper problem if copy & paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.

Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)

the wikipedia links are confusing enough

http://en.wikipedia.org/wiki/Descendant links to:
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file

So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.

I'd sooner see Node.getElementById and risk the confusion of it
returning fewer nodes than Document.getElementById.
Aaron Leventhal
2008-12-05 15:09:59 UTC
Permalink
How about node.getElementByIdInSubtree?
Post by timeless
Maybe there is a deeper problem if copy& paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.
Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)
the wikipedia links are confusing enough
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file
So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.
I'd sooner see Node.getElementById and risk the confusion of it
returning fewer nodes than Document.getElementById.
Calogero Alex Baldacchino
2008-12-05 18:19:04 UTC
Permalink
Post by Aaron Leventhal
How about node.getElementByIdInSubtree?
On Tue, Dec 2, 2008 at 10:39 AM, Aaron
Maybe there is a deeper problem if copy& paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.
Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)
the wikipedia links are confusing enough
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file
So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.
I'd sooner see Node.getElementById and risk the confusion of it
returning fewer nodes than Document.getElementById.
That's about the same then moving the getElementById method from the
Document interface to the Node interface
(Document inherits from Node, so the actual traversed subtree would
change basing on the node where the method is invocked, that is
'anElement = document.getElementById("anEl")' would work as always,
while anElement.getElementById("anEl") would look for a descendant of
'anElement' with the same id), because, essentially, IDs are a common
feature of all document types, despite the actual name of the attribute
representing an ID, so an eventual .getElementByIdInSubtree() method
should be defined on a somewhat DOM Core interface, and so would be out
of scope for HTML 5 (as I've been told .getElementById is - there is a
'Web DOM Core' specification under construction). But the term 'Subtree'
arises a problem with HTML 5: actually, the id attribute is defined as
the element unique ID in the *subtree* whithin which the element is
found. That is, the term subtree refers to a whole document tree, but
also to a disconnected subtree handled by a script (and I haven't yet
understood if such definition refers to a document fragment containing
nodes detached by any document, or a whole document without a browsing
context).

Perhaps the possible confusion arising if moving .getElementById() to
the Node interface might be avoided by leaving it on the document
interface, and overloading it with, for instance,

Element getElementById(in DOMString elementId, in Node rootElement);

so a call to document.getElementById would behave as always (or better,
as it will be redefined in Web DOM Core, that should be 'pick the first
element with a matching id'), and would coincide with a call to
document.getElementById("something", document); while a call to
document.getElementById("something", anElement) would search a matching
ID among the descendants of 'anElement', whether anElement be a node of
the current document, or a node removed by any document or created by a
script, or a node in another document and both the current document and
the current script context are enabled to access it (but a 'script
context' is an HTML 5 related concept, so it might be generalized as a
"DOM access context").

Regards, Alex


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Personalizza il tuo cellulare con tantissimi temi!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8275&d=5-12
Simon Pieters
2008-12-06 05:37:42 UTC
Permalink
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
That's about the same then moving the getElementById method from the
Document interface to the Node interface
(Document inherits from Node, so the actual traversed subtree would
change basing on the node where the method is invocked, that is
'anElement = document.getElementById("anEl")' would work as always,
while anElement.getElementById("anEl") would look for a descendant of
'anElement' with the same id), because, essentially, IDs are a common
feature of all document types, despite the actual name of the attribute
representing an ID, so an eventual .getElementByIdInSubtree() method
should be defined on a somewhat DOM Core interface, and so would be out
of scope for HTML 5 (as I've been told .getElementById is - there is a
'Web DOM Core' specification under construction).
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
Post by Calogero Alex Baldacchino
But the term 'Subtree' arises a problem with HTML 5: actually, the id
attribute is defined as the element unique ID in the *subtree* whithin
which the element is found. That is, the term subtree refers to a whole
document tree, but also to a disconnected subtree handled by a script
(and I haven't yet understood if such definition refers to a document
fragment containing nodes detached by any document, or a whole document
without a browsing context).
AIUI, it could also be a disconnected element.
Post by Calogero Alex Baldacchino
Perhaps the possible confusion arising if moving .getElementById() to
the Node interface might be avoided by leaving it on the document
interface, and overloading it with, for instance,
Element getElementById(in DOMString elementId, in Node rootElement);
You mean that it would only be possible to look for elements that are in
the document (effectively adding it purely for the case when there are
duplicate IDs in a document -- which is invalid)?
Post by Calogero Alex Baldacchino
so a call to document.getElementById would behave as always (or better,
as it will be redefined in Web DOM Core, that should be 'pick the first
element with a matching id'), and would coincide with a call to
document.getElementById("something", document); while a call to
document.getElementById("something", anElement) would search a matching
ID among the descendants of 'anElement', whether anElement be a node of
the current document, or a node removed by any document or created by a
script, or a node in another document and both the current document and
the current script context are enabled to access it (but a 'script
context' is an HTML 5 related concept, so it might be generalized as a
"DOM access context").
Hmm. If you allow it to work on disconnected nodes, why involve the
'document' at all instead of using Node.getElementById? I think that's
adding to the confusion. :-)

Anyway, apart from implementing the HTML5 table heading algorithm in
JavaScript, what are the use cases for this? Given that there's
Element|Document|DocumentFragment.querySelector('#id') which will return
the first element with that ID in the given subtree, and that
Node.getElementById seems to mostly encourage using duplicate IDs, I'm
reluctant to add it to Web DOM Core. UAs can still have such a method
internally if they need it.
--
Simon Pieters
Opera Software
Calogero Alex Baldacchino
2008-12-07 03:09:01 UTC
Permalink
Post by Simon Pieters
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
[...]
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
I'm reading it :-)

And I have a few questions. First, is it meant as the reference DOM Core
for HTML 5 only, or in general (for other kinds of markup too)?

The 'children' attribute on the Element interface, being an
HTMLCollection instance, suggests me the former might be the answer;
otherwise, either the reference to a specific document DOM interface, or
(in the case such interface were moved into Web DOM Core) the reference
to a specific dom in the name of the interface might perhaps be
problematic (formally, at least). I guess such attribute has been
declared on the Element interface instead of the HTMLElement one because
actually this is the most common implementation in current browsers.
Anyway, let me suggest (just as a hint, after all a working draft is the
right phase to explore any alternative) something like an
ElementCollection interface with the same properties of HTMLCollection,
making the latter just inheriting from the former as if it were an alias
(the same way DocumentFragment inherits from Node). On any browser
implementing 'children' as an HTMLCollection (without any hierarchy),
this shouldn't be a problem for scripts, since a script language usually
provides runtime inferred types; for languages with strong types (and
perhaps here we're moving from scripts to plugins), the access strategy
may be implementation specific but, as far as the hierarchy of
interfaces (ElementCollection -> HTMLCollection) does not change the
properties of an object implementing the HTMLCollection, that shouldn't
be a lot to work around. For instance, a Java applet (as well as any
other object implementing LiveConnect) should work fine using the
JSObject without any modify, while a direct access to the DOM would need
a DOMServiceProvider implementation (I'm not aware of any granting
access to the 'children' attribute, or better, to any non-W3C DOM
properties, but I guess as soon as your proposal became a recommendation
at least Sun would update such in Java APIs); for such purpose,
suggesting that any object provided by the user agent as implementing
either interface should be wrapped by an object also implementing the
other, for backward compatibility, might be enough (anyway, this is no
more than a hint, a very early feedback).

I see the Element interface no more contains methods to handle Attr
nodes: since those are described as not being child nodes of an Element,
in W3C specifications, there will be any other way to handle attributes
as nodes, the 'nature' of Attr nodes is going to change, or is there a
too little use (and/or support) of them, such that the Attr interface
might be quite close to its 'end of life'? Apart from that, I've also
noted the 'isId' attribute has been removed from Attr; I was thinking
just to that when I've read, in HTML 5 spec, that "This specification
doesn't preclude an element having multiple IDs, if other mechanisms
(e.g. DOM Core methods) can set an element's ID in a way that doesn't
conflict with the id attribute". For this purpose, either the 'isId'
property of an Attr node, or a mechanism to set an Element's attribute
as an alternative ID (or both) might be helpful (anyway, having more
then one unique identifier to handle for each element|| in a document
might cause an increase in duplicated IDs).

The above takes me to the '.getElementsByClassName()' method: if it were
to be moved from HTML 5 spec to Web DOM Core API, and if the latter is
meant as some kind of replacement for W3C DOM level 3, perhaps, for
generality sake, such method might be defined as referring to a property
named CLASS (along the same lines as ID), pointing out that such
property might not be binded to an attribute named 'class' (just to make
the spec ready in case the need to support such sort of document arose
in the near future, without having to change web dom core, or to derive
a new version, only for this reason).

But now let's come to your questions (sorry for the digression,
sometimes I can't help starting this way...)
Post by Simon Pieters
Post by Calogero Alex Baldacchino
But the term 'Subtree' arises a problem with HTML 5: actually, the id
attribute is defined as the element unique ID in the *subtree*
whithin which the element is found. That is, the term subtree refers
to a whole document tree, but also to a disconnected subtree handled
by a script (and I haven't yet understood if such definition refers
to a document fragment containing nodes detached by any document, or
a whole document without a browsing context).
AIUI, it could also be a disconnected element.
And I've suggested, in another mail, to clarify it, i.e. telling a
subtree is either a whole document (to make clearer that '<body><div
id="the_id" >....</div> <div> ... <div id="the_id" /> </div> </body>' is
always illegal, regardless the possibility to separate two different
subtrees in the same document where the id 'the_id' is unique), or a
group of one or more 'related' disconnected nodes (i.e. a node removed
from a document with its descendants, a cloned node, a newly created
one, and so on, that is, in practice, about any tree of nodes without an
ownerDocument).

However, how is the ID uniqueness to be related to current APIs with
respect to a disconnected subtree? I mean, if such were relevant for any
method, such as a .getElementById variant handling disconnected
elements, the "uniqueness rule" would be quite self-explaining: either
such a method fails in front of duplicated IDs, or it returns the very
first match (or does whatever else is established to degrade
gracefully). But if the subtree traversal/id searching implementation is
up to a script programmer, the 'id' attribute may be seen as any other
attribute, and the programmer may opt for considering the uniqueness of
IDs as non relevant to his/her code in 'off-document' manipulations,
until the subtree is inserted into a document. Thus, maybe, IDs
uniqueness should be related to anything being under direct control of
current APIs (such as documents).

For the rest, my considerations on [whatever].getElementById() were
general, not referred to a concrete use case (partly being driven by the
above thoughts), and, for what concerns the email you've replied,
Post by Simon Pieters
On Tue, Dec 2, 2008 at 10:39 AM, Aaron
Post by Calogero Alex Baldacchino
Maybe there is a deeper problem if copy& paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.
Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)
the wikipedia links are confusing enough
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file
So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.
I'd sooner see Node.getElementById and risk *the confusion of it
returning fewer nodes than Document.getElementById.*
I guessed the confusion he was concerning might be caused by the general
confidence people have with .getElementById working on the whole
document, so that someone might think, after discovering somehow there
is a getElementById method on every Node (or better, on every element in
an HTML document), such being working on the whole document as well,
thus expecting more non null results than a Node.getElementById method
might return, in general (people anyway should be confident with
Document.getElementsByTagName working on the whole document while
Element.getElementsByTagName working on an element descendants... but
without a crystal ball to guess it, who knows...). Thus, if the above
were the case, I've suggested something like
document.getElementById("the_id", startNode), to focus (perhaps!) the
attention of the average programmer (the same who might have thought
'anElement.getElementById' being the same as 'document.getElementById')
on the different behaviour, by 'forcing' the indication of a new
argument specifying where to start the search (that is, something
totally new to the programmer).

I agree that encouraging duplicate IDs is not any good idea, and
whatever method looking for IDs in a document subtree might take to
that. I really don't like the bare idea of a duplicated ID -- it's a
somewhat conflicting logic -- and I'm tempted to say a duplicate should
always break correct execution, especially when the duplicate comes from
an 'error' in scripting (as when inserting a cloned node without caring
of side-effects), because, at first glance, I'd regard a duplicate ID as
whatever else bug making a stand-alone application crashing because of
side-effects (of course, I'm not telling the browser should crash!),
and, after all, a gracefully degrading .getElementById (returning the
very first matching element) cannot prevent side-effects. But I really
understand, also, duplicate IDs are a common problem asking for a
solution, or at least a standard graceful degradation (such as the one
stated for document.getElementById(elementId)).

From this point of view, and also having in mind a disconnected subtree
to deal with through the API, maybe something like
document.getElementById(elementId, rootElement) might make sense if it
worked _only_ on disconnected subtrees, by first checking whether the
passed node (or the first descendent not being a document fragment node)
is effectively disconnected (not in the document), then returning the
matching element (if any), or null if the traversed subtree is instead
in the document tree (or even ending with an exception, to encourage a
greater attention and immediately tell the reason of the failure --
returning null might be ambiguous, since that's the same result when no
matching element is found).

But such method might be confusing, I agree (perhaps might confusion be
avoided by calling the method getExternalElementById?), and might also
provide a quite easy way to look for duplicate IDs (e.g. by creating a
fake document and calling that method on a subtree of another,
manipulated document -- but such would be a bit tricky, and if I do
something tricky, I should know that's not the better way to achieve
some result).

---

Now, let me fly back again off topic on Web DOM Core. Sometime elements
are conceived to be somewhat leaf elements, conceptually not being
enabled to have any sort of descendants (this is the case for <br> or
<base>, i.e., in HTML); yet they're Elements, and Nodes (and
HTMLElements), thus having attributes and methods allowing, in theory,
some weird manipulation. I don't know what every browser currently does
(honestly, I've never tried -- this is a recent doubt of mine), but I
guess the result might vary from one UA to another, and something
inappropriate might happen (in any case, there is no standard way to
block such). Perhaps, a new (readonly) property might be defined on Node
telling the node is a "definitive leaf", so that whatever
property/method might be declared as inaccessible/failing (e.g. throwing
an exception) if the 'isLeaf' property were true -- such an attribute
cannot be neither an Element, nor an HTMLElement, nor an HTMLElement
derived interface property, since there are methods on the Node
interface involved too, and as well the nodeType attribute wouldn't cope
well with this, because that should work for instances of the same type,
or regardless the type -- in other words, when trying and changing the
descendant hierarchy of a node with a true value for such an attribute,
the result should be an illegal hierarchy. Do you think such might be
worth to be considered?

(before I forget it, current definition of legal hierarchy seems to cut
out some legal cases, such as, for instance, an Element with no Text
child nodes, and the alike -- perhaps, should it be converted into a
list of illegal hierarchies? the resulting list would cover fewer cases
than a complete list of legal scenarios - if I haven't misunderstood it).

Best Regards,
Alex.


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
CAPODANNO A RIMINI HOTEL 2 STELLE
* 2 notti pernottamento con colazione a buffet euro 70,00, 3 notti euro 90,00
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8500&d=7-12
Simon Pieters
2008-12-08 06:11:41 UTC
Permalink
On Sun, 07 Dec 2008 04:09:01 +0100, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
I'm reading it :-)
And I have a few questions. First, is it meant as the reference DOM Core
for HTML 5 only, or in general (for other kinds of markup too)?
In general.
Post by Calogero Alex Baldacchino
The 'children' attribute on the Element interface, being an
HTMLCollection instance, suggests me the former might be the answer;
otherwise, either the reference to a specific document DOM interface, or
(in the case such interface were moved into Web DOM Core) the reference
to a specific dom in the name of the interface might perhaps be
problematic (formally, at least).
Is it the name "HTMLCollection" that is the problem?
Post by Calogero Alex Baldacchino
I guess such attribute has been declared on the Element interface
instead of the HTMLElement one because actually this is the most common
implementation in current browsers.
Right. Also because it seems useful for not just HTML.
Post by Calogero Alex Baldacchino
Anyway, let me suggest (just as a hint, after all a working draft is the
right phase to explore any alternative) something like an
ElementCollection interface with the same properties of HTMLCollection,
making the latter just inheriting from the former as if it were an alias
(the same way DocumentFragment inherits from Node). On any browser
implementing 'children' as an HTMLCollection (without any hierarchy),
this shouldn't be a problem for scripts, since a script language usually
provides runtime inferred types; for languages with strong types (and
perhaps here we're moving from scripts to plugins), the access strategy
may be implementation specific but, as far as the hierarchy of
interfaces (ElementCollection -> HTMLCollection) does not change the
properties of an object implementing the HTMLCollection, that shouldn't
be a lot to work around. For instance, a Java applet (as well as any
other object implementing LiveConnect) should work fine using the
JSObject without any modify, while a direct access to the DOM would need
a DOMServiceProvider implementation (I'm not aware of any granting
access to the 'children' attribute, or better, to any non-W3C DOM
properties, but I guess as soon as your proposal became a recommendation
at least Sun would update such in Java APIs); for such purpose,
suggesting that any object provided by the user agent as implementing
either interface should be wrapped by an object also implementing the
other, for backward compatibility, might be enough (anyway, this is no
more than a hint, a very early feedback).
This seems like adding complexity for political reasons.
Post by Calogero Alex Baldacchino
I see the Element interface no more contains methods to handle Attr
nodes: since those are described as not being child nodes of an Element,
in W3C specifications, there will be any other way to handle attributes
as nodes, the 'nature' of Attr nodes is going to change, or is there a
too little use (and/or support) of them, such that the Attr interface
might be quite close to its 'end of life'?
I'm not sure what to do with attributes. I'd like to drop support for
attribute nodes (being moved around, etc), if possible, but keep the
.attributes list and be able to use .value etc on each attribute.
Post by Calogero Alex Baldacchino
Apart from that, I've also noted the 'isId' attribute has been removed
from Attr;
Right, it hasn't been implemented in the top 4 browsers and it seems like
a not-so-useful feature to have.
Post by Calogero Alex Baldacchino
I was thinking just to that when I've read, in HTML 5 spec, that "This
specification doesn't preclude an element having multiple IDs, if other
mechanisms (e.g. DOM Core methods) can set an element's ID in a way that
doesn't conflict with the id attribute".
It says this, AIUI, because other specs do make it possible, not because
it's a good idea that it is possible. Personally I think it should not be
possible (specifically I think 'id' should be like 'xml:id' is and all
other ways to get an ID-like attribute should be dropped).
Post by Calogero Alex Baldacchino
For this purpose, either the 'isId' property of an Attr node, or a
mechanism to set an Element's attribute as an alternative ID (or both)
might be helpful (anyway, having more then one unique identifier to
handle for each element|| in a document might cause an increase in
duplicated IDs).
It's not clear to me why it would be helpful.
Post by Calogero Alex Baldacchino
The above takes me to the '.getElementsByClassName()' method: if it were
to be moved from HTML 5 spec to Web DOM Core API, and if the latter is
meant as some kind of replacement for W3C DOM level 3, perhaps, for
generality sake, such method might be defined as referring to a property
named CLASS (along the same lines as ID), pointing out that such
property might not be binded to an attribute named 'class' (just to make
the spec ready in case the need to support such sort of document arose
in the near future, without having to change web dom core, or to derive
a new version, only for this reason).
That's how it's defined in HTML5 already.
Post by Calogero Alex Baldacchino
But now let's come to your questions (sorry for the digression,
sometimes I can't help starting this way...)
Post by Simon Pieters
Post by Calogero Alex Baldacchino
But the term 'Subtree' arises a problem with HTML 5: actually, the id
attribute is defined as the element unique ID in the *subtree* whithin
which the element is found. That is, the term subtree refers to a
whole document tree, but also to a disconnected subtree handled by a
script (and I haven't yet understood if such definition refers to a
document fragment containing nodes detached by any document, or a
whole document without a browsing context).
AIUI, it could also be a disconnected element.
And I've suggested, in another mail, to clarify it, i.e. telling a
subtree is either a whole document (to make clearer that '<body><div
id="the_id" >....</div> <div> ... <div id="the_id" /> </div> </body>' is
always illegal, regardless the possibility to separate two different
subtrees in the same document where the id 'the_id' is unique),
AIUI, the 'subtree' in HTML5 means the tree from the top-most ancestor.
The spec could be clearer about this.
Post by Calogero Alex Baldacchino
or a group of one or more 'related' disconnected nodes (i.e. a node
removed from a document with its descendants, a cloned node, a newly
created one, and so on, that is, in practice, about any tree of nodes
without an ownerDocument).
Don't nodes always have an ownerDocument?
Post by Calogero Alex Baldacchino
However, how is the ID uniqueness to be related to current APIs with
respect to a disconnected subtree? I mean, if such were relevant for any
method, such as a .getElementById variant handling disconnected
elements, the "uniqueness rule" would be quite self-explaining: either
such a method fails in front of duplicated IDs, or it returns the very
first match (or does whatever else is established to degrade
gracefully). But if the subtree traversal/id searching implementation is
up to a script programmer, the 'id' attribute may be seen as any other
attribute, and the programmer may opt for considering the uniqueness of
IDs as non relevant to his/her code in 'off-document' manipulations,
until the subtree is inserted into a document. Thus, maybe, IDs
uniqueness should be related to anything being under direct control of
current APIs (such as documents).
Are you arguing that HTML5 should remove the requirement about unique IDs
for nodes not in a document?
Post by Calogero Alex Baldacchino
For the rest, my considerations on [whatever].getElementById() were
general, not referred to a concrete use case (partly being driven by the
above thoughts),
Ok.
Post by Calogero Alex Baldacchino
and, for what concerns the email you've replied, started from the
Post by Simon Pieters
Post by Calogero Alex Baldacchino
Maybe there is a deeper problem if copy& paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.
Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)
the wikipedia links are confusing enough
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file
So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.
I'd sooner see Node.getElementById and risk *the confusion of it
returning fewer nodes than Document.getElementById.*
I guessed the confusion he was concerning might be caused by the general
confidence people have with .getElementById working on the whole
document, so that someone might think, after discovering somehow there
is a getElementById method on every Node (or better, on every element in
an HTML document), such being working on the whole document as well,
thus expecting more non null results than a Node.getElementById method
might return, in general (people anyway should be confident with
Document.getElementsByTagName working on the whole document while
Element.getElementsByTagName working on an element descendants... but
without a crystal ball to guess it, who knows...). Thus, if the above
were the case, I've suggested something like
document.getElementById("the_id", startNode), to focus (perhaps!) the
attention of the average programmer (the same who might have thought
'anElement.getElementById' being the same as 'document.getElementById')
on the different behaviour, by 'forcing' the indication of a new
argument specifying where to start the search (that is, something
totally new to the programmer).
I agree that encouraging duplicate IDs is not any good idea, and
whatever method looking for IDs in a document subtree might take to
that. I really don't like the bare idea of a duplicated ID -- it's a
somewhat conflicting logic -- and I'm tempted to say a duplicate should
always break correct execution, especially when the duplicate comes from
an 'error' in scripting (as when inserting a cloned node without caring
of side-effects), because, at first glance, I'd regard a duplicate ID as
whatever else bug making a stand-alone application crashing because of
side-effects (of course, I'm not telling the browser should crash!),
and, after all, a gracefully degrading .getElementById (returning the
very first matching element) cannot prevent side-effects. But I really
understand, also, duplicate IDs are a common problem asking for a
solution, or at least a standard graceful degradation (such as the one
stated for document.getElementById(elementId)).
From this point of view, and also having in mind a disconnected subtree
to deal with through the API, maybe something like
document.getElementById(elementId, rootElement) might make sense if it
worked _only_ on disconnected subtrees, by first checking whether the
passed node (or the first descendent not being a document fragment node)
is effectively disconnected (not in the document), then returning the
matching element (if any), or null if the traversed subtree is instead
in the document tree (or even ending with an exception, to encourage a
greater attention and immediately tell the reason of the failure --
returning null might be ambiguous, since that's the same result when no
matching element is found).
But such method might be confusing, I agree (perhaps might confusion be
avoided by calling the method getExternalElementById?), and might also
provide a quite easy way to look for duplicate IDs (e.g. by creating a
fake document and calling that method on a subtree of another,
manipulated document -- but such would be a bit tricky, and if I do
something tricky, I should know that's not the better way to achieve
some result).
I guess the best way to avoid confusion is to not add the feature at all.
:-)
Post by Calogero Alex Baldacchino
---
Now, let me fly back again off topic on Web DOM Core. Sometime elements
are conceived to be somewhat leaf elements, conceptually not being
enabled to have any sort of descendants (this is the case for <br> or
<base>, i.e., in HTML); yet they're Elements, and Nodes (and
HTMLElements), thus having attributes and methods allowing, in theory,
some weird manipulation.
Right. <br> can have children by using XHTML or by DOM manipulation.
Post by Calogero Alex Baldacchino
I don't know what every browser currently does (honestly, I've never
tried -- this is a recent doubt of mine),
Opera, Firefox and Safari don't throw. IE does.
Post by Calogero Alex Baldacchino
but I guess the result might vary from one UA to another, and something
inappropriate might happen (in any case, there is no standard way to
block such). Perhaps, a new (readonly) property might be defined on Node
telling the node is a "definitive leaf", so that whatever
property/method might be declared as inaccessible/failing (e.g. throwing
an exception) if the 'isLeaf' property were true -- such an attribute
cannot be neither an Element, nor an HTMLElement, nor an HTMLElement
derived interface property, since there are methods on the Node
interface involved too, and as well the nodeType attribute wouldn't cope
well with this, because that should work for instances of the same type,
or regardless the type -- in other words, when trying and changing the
descendant hierarchy of a node with a true value for such an attribute,
the result should be an illegal hierarchy. Do you think such might be
worth to be considered?
I don't understand why it would be useful.
Post by Calogero Alex Baldacchino
(before I forget it, current definition of legal hierarchy seems to cut
out some legal cases, such as, for instance, an Element with no Text
child nodes, and the alike -- perhaps, should it be converted into a
list of illegal hierarchies? the resulting list would cover fewer cases
than a complete list of legal scenarios - if I haven't misunderstood it).
Um. Yeah. Actually it rules out everything (a node can't be a Document and
a Text node at the same time, for instance). I think i'll move the
checking into each algorithm that's adding stuff to the tree instead (in
due course).


Thanks for the feedback,
--
Simon Pieters
Opera Software
Calogero Alex Baldacchino
2008-12-08 21:30:32 UTC
Permalink
Post by Simon Pieters
On Sun, 07 Dec 2008 04:09:01 +0100, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
I'm reading it :-)
And I have a few questions. First, is it meant as the reference DOM
Core for HTML 5 only, or in general (for other kinds of markup too)?
In general.
Ok.
Post by Simon Pieters
Is it the name "HTMLCollection" that is the problem?
Perhaps. I don't know and can't guess how much 'political consensus'
might be needed to make the specification fly (especially if trying a
convergence with w3c). Maybe, the support of the main browsers vendors
is more than enough, and a name is not much of a problem in practice.
Anyway, since that's just a formal/political matter, that may be solved
when and if needed, I've just pointed out a possible solution (but I'm
sure you don't need my suggestions to get there, or to find a better one
:-P).
Post by Simon Pieters
Post by Calogero Alex Baldacchino
I guess such attribute has been declared on the Element interface
instead of the HTMLElement one because actually this is the most
common implementation in current browsers.
Right. Also because it seems useful for not just HTML.
Well, on one hand it duplicates a NodeList of child nodes, but on the
other hand only Element nodes are listed, and this can be useful in
practice, I agree. :-)
Post by Simon Pieters
Post by Calogero Alex Baldacchino
Anyway, let me suggest [..]
This seems like adding complexity for political reasons.
Hmm, for a script no complexity would be added (I mean, a script engine
embedded in a UA would implement the same interface as the UA, but the
script code would work fine because of runtime inferred types -- the
instanceof operator, in ECMAScript, might fail indeed, but such may fail
anyway in IE, which seems not to expose the DOM hierarchy of an object).
LiveConnect should work fine as well; any other access to the DOM
through a plugin may require a whole implementation to make new DOM
property types/interfaces available as compile-time known
types/interfaces (I'm not sure, but I think that Java, actually, doesn't
provide access to non w3c dom 2 properties -- true, at least, for some
versions of the VM and related DOMAccessProvider objects; I don't know
if there are third parties implementations allowing that -- and I also
guess some non-standard interface might be adopted, in implementations,
to give access to every properties of an html document without having
always to cast to the proper interface, since HTMLDocument no more
inherits from Document). Such an implementation might require objects
wrapping at some point (e.g. to maintain consistency between
corresponding data types), thus adding a constraint to anything likely
yet needed shouldn't be too expensive for the implementors. Anyway, yes,
that's mainly a formal/political need, and obviously can be added as
needed (as above, :-P)
Post by Simon Pieters
I'm not sure what to do with attributes. I'd like to drop support for
attribute nodes (being moved around, etc), if possible, but keep the
.attributes list and be able to use .value etc on each attribute.
Good question. Unless moving .value/.name on the Node interface (which I
guess might be problematic for backward compatibility), a Node-derived
interface is needed to accomplish that, unless changing the list
'nature' as well (but with similar issues, and not solving the need for
an interface defining the .value and .name interface)...
Post by Simon Pieters
Post by Calogero Alex Baldacchino
I was thinking just to that when I've read, in HTML 5 spec, that
"This specification doesn't preclude an element having multiple IDs,
if other mechanisms (e.g. DOM Core methods) can set an element's ID
in a way that doesn't conflict with the id attribute".
It says this, AIUI, because other specs do make it possible, not
because it's a good idea that it is possible.
I understand it the same way (and guess such specs might allow custom ID
attributes).
Post by Simon Pieters
Personally I think it should not be possible (specifically I think
'id' should be like 'xml:id' is and all other ways to get an ID-like
attribute should be dropped).
I agree. But I'm not sure if that's a 'safe' choice in a general DOM
(maybe it is considering actual needs; if support for those other ways
were needed in the future, it might always be added in a future
version/revision of Web DOM Core, and wouldn't conflict with html 5
spec, in reason of that statement -- backward compatibility'd be no more
problematic than it is today for new HTML tags, but changes and breaks
are unavoidable if they're good evolutions - unless there is yet some
degree of support for ID-like attributes, so the break might be less
safe, but I guess that's not the case).
Post by Simon Pieters
Post by Calogero Alex Baldacchino
For this purpose, either the 'isId' property of an Attr node, or a
mechanism to set an Element's attribute as an alternative ID (or
both) might be helpful [...]
It's not clear to me why it would be helpful.
If ID-like attributes were to be supported, specially user defined ones,
providing any mechanism to set such attributes and/or check their
'nature' might be useful both in script (i.e. when manipulating the DOM
and willing to treat ID-like attributes differently from other
attributes, in order to just check their nature instead of looking for
matching names) and perhaps for the DOM itself (anyway, methods such
.getElementById() would need only an implementation-level knowledge of
the attribute nature - that is, just to rely on an internal property,
but exposing such a property wouldn't be a ugly choice). However, if
ID-like attributes won't be supported, there is no need for any suitable
mechanism to handle them, of course.
Post by Simon Pieters
Post by Calogero Alex Baldacchino
The above takes me to the '.getElementsByClassName()' method: if it
were to be moved from HTML 5 spec to Web DOM Core API, and if the
latter is meant as some kind of replacement for W3C DOM level 3,
perhaps, for generality sake, such method might be defined as
referring to a property named CLASS (along the same lines as ID),
pointing out that such property might not be binded to an attribute
named 'class' (just to make the spec ready in case the need to
support such sort of document arose in the near future, without
having to change web dom core, or to derive a new version, only for
this reason).
That's how it's defined in HTML5 already.
Indeed, HTML5 defines such method behaviour without referring to the
actual class-attribute, but in the end explicitly refers to it for HTML,
MathML and SVG elements. Maybe that part might be modified when moving
the method from HTML5 spec to a more general DOM spec, and I wondered
whether pointing out that a class-attribute may have any name different
from 'class' (perhaps leaving the reference to a somewhat document type
as an example), the same way DOM 3 Core does it for IDs, might have been
a nice formalism.
Post by Simon Pieters
AIUI, the 'subtree' in HTML5 means the tree from the top-most
ancestor. The spec could be clearer about this.
Yes, that's its meaning. In a previous mail, Ian Hickson answered me
such term was chosen to formalize conformance for disconnected trees
handled by scripts.
Post by Simon Pieters
Don't nodes always have an ownerDocument?
Yes, the always have one... I don't know where my head was when writing
that... I should have referred to the parentNode property (which is null
for removed an cloned nodes, for instance), and/or the topmost node not
being a (html)document node.
Post by Simon Pieters
Are you arguing that HTML5 should remove the requirement about unique
IDs for nodes not in a document?
Let me clarify I'm not aiming to argue with anyone about anything. I'm
just trying and showing an alternative point of view, hoping it may be
helpful in the process of spec definition.

I'm not sure if a conformance rule for an HTML document may apply in
such a case, even because a disconnected subtree might come from a
non-HTML document (I'm not necessarily referring to an existing one,
since HTML5 spec is thought to define conformance rules also for future
UAs willing to handle 'older' html5 documents: such UAs might support
any kind of document embedding html tags the same way html5 allows
embedding MathML and SVG tags, and such a 'new' kind of document might
have relaxed requirements for ids, thus I think HTML5 rules should not
conflict with such, or better, should not define rules for HTML elements
possibly originated outside an HTML document). Anyway, an ID is an ID
and an HTML element's id attribute represents the default ID property
for its element in any kind of subtree, so, perhaps, indicating such as
relevant for any api dealing with ID properties, and requiring
conformance with HTML rules for any subtree to be inserted in any HTML
document (where duplicate IDs are illegal), instead of declaring
id-attribute values as always unique, might be reasonable. That's all
(and I understand, perhaps that's splitting hairs).
Post by Simon Pieters
I guess the best way to avoid confusion is to not add the feature at
all. :-)
That's ok for me. Unless a real need for handling unique IDs in
disconnected subtree arose, avoiding that is a good choice. :-)
Post by Simon Pieters
Post by Calogero Alex Baldacchino
[...]
Right. <br> can have children by using XHTML or by DOM manipulation.
Post by Calogero Alex Baldacchino
I don't know what every browser currently does (honestly, I've never
tried -- this is a recent doubt of mine),
Opera, Firefox and Safari don't throw. IE does.
Post by Calogero Alex Baldacchino
but I guess the result might vary from one UA to another, and
something inappropriate might happen (in any case, there is no
standard way to block such). Perhaps, a new (readonly) property might
be defined on Node telling the node is a "definitive leaf", so that
whatever property/method might be declared as inaccessible/failing
(e.g. throwing an exception) if the 'isLeaf' property were true --
such an attribute cannot be neither an Element, nor an HTMLElement,
nor an HTMLElement derived interface property, since there are
methods on the Node interface involved too, and as well the nodeType
attribute wouldn't cope well with this, because that should work for
instances of the same type, or regardless the type -- in other words,
when trying and changing the descendant hierarchy of a node with a
true value for such an attribute, the result should be an illegal
hierarchy. Do you think such might be worth to be considered?
I don't understand why it would be useful.
Well, in case the IE behaviour were chosen as standard (and only in this
case -- which might be consistent with HTML5 empty content model),
implementations would likely use an internal property to check when
deciding whether to block an element subtree creation/manipulation or
not. Exposing such a property might be useful to check the nature of an
element in a script, but maybe also to formalize the chosen standard
behaviour.
Post by Simon Pieters
Um. Yeah. Actually it rules out everything (a node can't be a Document
and a Text node at the same time, for instance). I think i'll move the
checking into each algorithm that's adding stuff to the tree instead
(in due course).
Such will work fine. :-)

Anyway, most checking will be the same, thus your original idea to
isolate such requirements in a unique list was nice (just needed to
become a list of what must not happen to have a legal hierarchy to
work). I think both choices are fine :-)
Post by Simon Pieters
Thanks for the feedback,
Happy to be helpful somehow, if I can. :-)
Regards, Alex.



--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
CAPODANNO A RIMINI HOTEL 2 STELLE
* 2 notti pernottamento con colazione a buffet euro 70,00, 3 notti euro 90,00
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8501&d=8-12
Jonas Sicking
2008-12-08 22:31:53 UTC
Permalink
Post by Simon Pieters
Post by Calogero Alex Baldacchino
I see the Element interface no more contains methods to handle Attr
nodes: since those are described as not being child nodes of an
Element, in W3C specifications, there will be any other way to handle
attributes as nodes, the 'nature' of Attr nodes is going to change, or
is there a too little use (and/or support) of them, such that the Attr
interface might be quite close to its 'end of life'?
I'm not sure what to do with attributes. I'd like to drop support for
attribute nodes (being moved around, etc), if possible, but keep the
.attributes list and be able to use .value etc on each attribute.
Oooh, this is an interesting idea. It'd be great if we could make
attributes not be nodes but rather some other type of object.

Ideally I'd like for them to not exist at all, and have people just use
getAttribute(NS) instead. I've never thought that their usefulness
outweighed their complexity.

/ Jonas
Calogero Alex Baldacchino
2008-12-08 23:47:11 UTC
Permalink
Post by Jonas Sicking
Post by Simon Pieters
Post by Calogero Alex Baldacchino
I see the Element interface no more contains methods to handle Attr
nodes: since those are described as not being child nodes of an
Element, in W3C specifications, there will be any other way to
handle attributes as nodes, the 'nature' of Attr nodes is going to
change, or is there a too little use (and/or support) of them, such
that the Attr interface might be quite close to its 'end of life'?
I'm not sure what to do with attributes. I'd like to drop support for
attribute nodes (being moved around, etc), if possible, but keep the
.attributes list and be able to use .value etc on each attribute.
Oooh, this is an interesting idea. It'd be great if we could make
attributes not be nodes but rather some other type of object.
Ideally I'd like for them to not exist at all, and have people just
use getAttribute(NS) instead. I've never thought that their usefulness
outweighed their complexity.
/ Jonas
Effectively, Attrs are nodes, but aren't used as 'normal' nodes; that's
complex. Perhaps they might have been defined as not inheriting from
Node since their introduction. If creating two new interfaces, one
replacing Attrs (perhaps called Attr as well, but not inheriting from
Node), the other to list attributes (AttributeCollection?), doesn't rise
any issue on backward compatibility, or it solves more problems than it
may create, that's not a bad idea. :-)

For sure, getting/setting an attribute as a property of an element,
through getter/setter methods taking and returning strings is easier and
perhaps the best choice in most cases, but there might be use cases
where the possibility to access an element's attributes as a list is
worth it, so, perhaps, should the drop of Attr be filed for a deep
analysis and a possible actuation in a successive version of Web DOM
Core (maybe modifying the Attr interface in the current)?


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Gioca e vinci con Sheba!
* Partecipa a concorso "I sensi di un'intesa perfetta" vinci fantastici premi per il tuo gatto!
*
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8433&d=9-12
ddailey
2008-12-09 02:38:44 UTC
Permalink
There are lots of times in which I've needed to examine one document by use
of a script that resides inside another. Using lists of attributes to do
that has been rather important, though if those lists were accessible as
properties of objects rather than as nodes themselves (as in some sort of
multinary relation rather than as a tree structure) that would be fine as
well. Learners of this stuff seem to have trouble with the fact that lists
cannot be indexed through array notation -- i.e., that nodes[1] cannot be
used in place of nodes.item(i) in some namespaces, but apparently can in
HTML.

Though I have only played a little with compound documents or with document
fragments, it seems like viewing all nodes as accessible through
getElementById is awfully dependent on how one finds the "document"
associated with the appropriate segment of a mixed NS document. In SVG
nestled inside HTML, for example, implementations have differed in terms of
how that document is retrieved as a function of browser, and the type of tag
(object, iframe, frame, or embed) in which the svg is placed. The ability to
"root" one's search directly at a certain level in the parent DOM, might
help in cases where mixed name spaces could lead to conflicts of the
assumption of unique id's.

Perhaps this has been addressed already, since I'm pretty sure the folks
involved in this conversation know more about what they are talking about
than I do.

cheers
David

----- Original Message -----
From: "Calogero Alex Baldacchino" <alex.baldacchino-06ZeP6ie+***@public.gmane.org>
To: "Jonas Sicking" <jonas-***@public.gmane.org>
Cc: "WHAT Working Group" <whatwg-***@public.gmane.org>; "Simon Pieters"
<simonp-***@public.gmane.org>
Sent: Monday, December 08, 2008 6:47 PM
Subject: Re: [whatwg] Use cases for Node.getElementById
Post by Calogero Alex Baldacchino
Post by Jonas Sicking
Post by Simon Pieters
Post by Calogero Alex Baldacchino
I see the Element interface no more contains methods to handle Attr
nodes: since those are described as not being child nodes of an
Element, in W3C specifications, there will be any other way to handle
attributes as nodes, the 'nature' of Attr nodes is going to change, or
is there a too little use (and/or support) of them, such that the Attr
interface might be quite close to its 'end of life'?
I'm not sure what to do with attributes. I'd like to drop support for
attribute nodes (being moved around, etc), if possible, but keep the
.attributes list and be able to use .value etc on each attribute.
Oooh, this is an interesting idea. It'd be great if we could make
attributes not be nodes but rather some other type of object.
Ideally I'd like for them to not exist at all, and have people just use
getAttribute(NS) instead. I've never thought that their usefulness
outweighed their complexity.
/ Jonas
Effectively, Attrs are nodes, but aren't used as 'normal' nodes; that's
complex. Perhaps they might have been defined as not inheriting from Node
since their introduction. If creating two new interfaces, one replacing
Attrs (perhaps called Attr as well, but not inheriting from Node), the
other to list attributes (AttributeCollection?), doesn't rise any issue on
backward compatibility, or it solves more problems than it may create,
that's not a bad idea. :-)
For sure, getting/setting an attribute as a property of an element,
through getter/setter methods taking and returning strings is easier and
perhaps the best choice in most cases, but there might be use cases where
the possibility to access an element's attributes as a list is worth it,
so, perhaps, should the drop of Attr be filed for a deep analysis and a
possible actuation in a successive version of Web DOM Core (maybe
modifying the Attr interface in the current)?
--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it http://www.email.it/f
Gioca e vinci con Sheba! * Partecipa a concorso "I sensi di un'intesa
http://adv.email.it/cgi-bin/foclick.cgi?mid=8433&d=9-12
Calogero Alex Baldacchino
2008-12-09 18:07:29 UTC
Permalink
Post by ddailey
There are lots of times in which I've needed to examine one document
by use of a script that resides inside another. Using lists of
attributes to do that has been rather important, though if those lists
were accessible as properties of objects rather than as nodes
themselves (as in some sort of multinary relation rather than as a
tree structure) that would be fine as well.
Well, attributes shouldn't be accessible as descendants of an Element in
a tree structure, but rather as items of a NamedNodeMap, or directly
through Element.getAttribute()/Element.getAttributeNS(), passing a
string representing the attribute name and getting the value as a
string. Thus, they don't need to be instances of Node (that's about
redefining Attr and a related listing interface to simplify the UA
handling of attributes, which currently are node but should be handled
as if they weren't). Any interface replacing Attr, for such purpose,
should take care of namespaces and prefixes (which is currently done in
DOM3 Node interface). Dropping the list of attributes as objects would
require to query each attribute by name, but a list of attributes seems
to be needed in some use cases; a DOMStringMap might be considered, to
represent attributes as a list of string couples of names and values,
but such couldn't handle namespaces, though it might be derived to add
such capability, nor it could solve the problem to define an interface
to give access to a tuple of (name, value, namespace) by colling, e.g.,
an item() method, or the alike. Otherwise, if no better alternative can
be found, Attrs will continue to be Nodes...
Post by ddailey
Learners of this stuff seem to have trouble with the fact that lists
cannot be indexed through array notation -- i.e., that nodes[1] cannot
be used in place of nodes.item(i) in some namespaces, but apparently
can in HTML.
I guess that's a matter of idl bindings, in part at least, so it might
be solved with clearer specific bindings, as needed. For instance, all
properties (attributes and methods) of a collection-like interface can
be declared [DontEnum], despite of them being defined on the idl or
being created at runtime (i.e. by listing an item as a named property of
the object), with the exception of indexed items: this way, a
collection-like object would always behave as an Array-like object.
Similarly, the collection might work as an associative array for named
items (i.e., the_id = attributes["id"] might work as the_id =
attributes.getNamedItem("id") ), but the binding for such might be more
complex, involving a redefinition of the bracket property accessor in
order to look for properties inside an internal list (when it comes to
implementations, such complexity may disappear or be reduced, for
instance, in C++ such might involve an "easy" overload of the
'operator[]' function).
Post by ddailey
Though I have only played a little with compound documents or with
document fragments, it seems like viewing all nodes as accessible
through getElementById is awfully dependent on how one finds the
"document" associated with the appropriate segment of a mixed NS
document. In SVG nestled inside HTML, for example, implementations
have differed in terms of how that document is retrieved as a function
of browser, and the type of tag (object, iframe, frame, or embed) in
which the svg is placed. The ability to "root" one's search directly
at a certain level in the parent DOM, might help in cases where mixed
name spaces could lead to conflicts of the assumption of unique id's.
Perhaps, what you're asking for is something like
Document.getNSElementById(in DOMString namespaceUri, in DOMString
elementId), to get access to the first element, in a document, whose tag
name has a prefix corresponding to the queried namespace, or is
descendant of an element whose tagname is the root element tag name for
the queried namespace (perhapse suitable for HTML 5 embedding <svg> or
<math> elements without prefixes). Anyway, you'd have to reach the
correct document first (but you'd have to do so to get the nested
content root element even with a getElementById(elementId, rootElement)
). Such method would involve a separate management of ids, one to ensure
uniqueness in the whole document (i.e. to return the first match for
getElementById despite of the element namespace), another to deal with
each element (either prefixed or just embedded) coming from the same
namespace as if they were in a separate document where to look for
unique ids (not to be implemented necessarily this way, just managing a
global map of unique IDs for all the elements in a document and zero or
more secondary maps for all the elements corresponding to a particular
namespace - different from that of the nesting document). Such might add
some complexity to the user agent, and perhaps won't get consensus from
implementors, I guess.

Regards, Alex.


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Dalla top ten al tuo cellulare. Scarica le superhit!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8268&d=9-12
Garrett Smith
2008-12-10 05:20:37 UTC
Permalink
On Sat, Dec 6, 2008 at 7:09 PM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Simon Pieters
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
[...]
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
I'm reading it :-)
And I have a few questions.
I did not see a proposal for Element.getElementById.

I would not care about that much.

I woud rather have

Element.getElementsByName.

It is perfectly valid for a doucment to have multiple elements w/the
same name (though not generally a good idea). I've seen this before.

Was this proposed?

Garrett
Calogero Alex Baldacchino
2008-12-10 16:10:06 UTC
Permalink
Post by Garrett Smith
On Sat, Dec 6, 2008 at 7:09 PM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Simon Pieters
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
[...]
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
I'm reading it :-)
And I have a few questions.
I did not see a proposal for Element.getElementById.
I would not care about that much.
I woud rather have
Element.getElementsByName.
It is perfectly valid for a doucment to have multiple elements w/the
same name (though not generally a good idea). I've seen this before.
Was this proposed?
Garrett
I don't remember what spec exactly stated this first, but I remind of a
previous HTML version declaring the 'name' attribute as unique in the
'global scope' (or something like that), meaning the whole document;
then, I remember 'name' was deprecated in favour of 'id'. I think
'getElementsByName' was retained from the past just because form
elements scoped input names in a different manner (while the name of an
anchor, for instance, had to be unique in the whole document), but it
was a bit conflicting with the uniqueness of (at least some) elements'
name. Anyway, this is what I remember (current specification no more
defines a name attribute for every elements - it's not on the
HTMLElement interface).

However, the issue about Node.getElementById originated by noticing
problems with duplicate ids in existing pages and the likelihood new
pages may have duplicate ids (e.g. by repeatedly cloning and inserting
nodes without caring of all attributes), thinking on the opportunity to
address such an illegal state somehow. If non-unique identifiers have to
be a deliberate and 'careful' choise, such to involve a dedicated
attribute, perhaps the class attribute and [ HTMLDocument | HTMLElement
| whatever_else_implementing ].getElementsByClassName() methods can
address that: classes are non-unique not only for the whole document,
but also for the same element, which may have multiple classes listed in
its attribute (each class name is unique in the list), so they might be
used for some non-style-related purposes, just appending a name to the
list of styling classes (just to give some clearness, though
unnecessary), and querying it with getElementsByClassName() would work
the same way as resorting to the 'name' attribute and the
'getElementsByName()' method (perhaps a bit tricky, but should work fine).

~~~~~~~~~~

@ Simon Pieters (and everyone else on the list, of course).

I was thinking again on 'getElementsByClassName()' moved to Web DOM
Core: maybe a good place for it might be the Node interface, so to have
the method working on Documents as well as on Elements; if the
HTMLCollection interface were moved as well, perhaps such might be the
return value, instead of a NodeList, since non-element Nodes should
never be expected to have a class name, I guess (perhaps doing the same
with getElementsByTagName might be consistent, but maybe problematic
because of backward compatibility -- while getElementsByClassName would
be a 'new entry' in the 'reign' of Core interfaces, thus a greater
degree of freedom might be taken, if reasonable, of course - it may
depend on a known need for different, specilized algorithms in Document
and Element nodes, for instance).

Best regards,
Alex


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
RC Auto?
* Con Direct Line garanzia furto e incendio a soli 30 € per un anno! Non perdere l’occasione!
*
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8497&d=10-12
Garrett Smith
2008-12-10 17:17:40 UTC
Permalink
On Wed, Dec 10, 2008 at 8:10 AM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Garrett Smith
On Sat, Dec 6, 2008 at 7:09 PM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Simon Pieters
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
[...]
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
I'm reading it :-)
And I have a few questions.
I did not see a proposal for Element.getElementById.
I would not care about that much.
I woud rather have
Element.getElementsByName.
It is perfectly valid for a doucment to have multiple elements w/the
same name (though not generally a good idea). I've seen this before.
Was this proposed?
Garrett
I don't remember what spec exactly stated this first, but I remind of a
previous HTML version declaring the 'name' attribute as unique in the
'global scope' (or something like that),
What?
Post by Calogero Alex Baldacchino
meaning the whole document; then, I
remember 'name' was deprecated in favour of 'id'.
Name is not deprecated. It is, as I said, "perfectly valid". How else
are you going to submit form values?

Garrett
Calogero Alex Baldacchino
2008-12-10 19:21:21 UTC
Permalink
Post by Garrett Smith
On Wed, Dec 10, 2008 at 8:10 AM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Garrett Smith
On Sat, Dec 6, 2008 at 7:09 PM, Calogero Alex Baldacchino
Post by Calogero Alex Baldacchino
Post by Simon Pieters
On Fri, 05 Dec 2008 19:19:04 +0100, Calogero Alex Baldacchino
[...]
(I'm currently the editor of that proposal, currently located at
http://simon.html5.org/specs/web-dom-core )
I'm reading it :-)
And I have a few questions.
I did not see a proposal for Element.getElementById.
I would not care about that much.
I woud rather have
Element.getElementsByName.
It is perfectly valid for a doucment to have multiple elements w/the
same name (though not generally a good idea). I've seen this before.
Was this proposed?
Garrett
I don't remember what spec exactly stated this first, but I remind of a
previous HTML version declaring the 'name' attribute as unique in the
'global scope' (or something like that),
What?
Post by Calogero Alex Baldacchino
meaning the whole document; then, I
remember 'name' was deprecated in favour of 'id'.
Name is not deprecated. It is, as I said, "perfectly valid". How else
are you going to submit form values?
Garrett
I was referring to some elements using it as a global identifier, like
<a> and <img>, and apologize for any lack of clearness.

From http://www.w3.org/TR/html401/struct/links.html#adef-name-A

"This attribute names the current anchor so that it may be the
destination of another link. The value of this attribute must be a
unique anchor name. The scope of this name is the current document. Note
that this attribute shares the same name space as the id attribute"
<http://www.w3.org/TR/html401/struct/global.html#adef-id>

From http://www.w3.org/TR/html401/struct/objects.html#adef-name-IMG

"This attribute names the element so that it may be referred to from
style sheets or scripts. Note.** This attribute has been included for
backwards compatibility. Applications should use the id attribute to
identify elements"

From http://www.w3.org/TR/html401/struct/links.html#anchors-with-id

"The id and name attributes share the same namespace.This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET, FORM,
FRAME, IFRAME, IMG and MAP. When both attributes are used on a single
element, their values must be identical."

You'll find neither html 4.01, nor html 5 declare a 'name' attribute for
every element (some of html 5 elements have lost their older 'name'
attribute, though it might be handled by the parser for backwards
compatibility, i.e. for the <a> element representing a fragment of the
document).


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
CheBanca! La prima banca che ti dà gli interessi in anticipo.
* Fino al 4,70% sul Conto Deposito, zero spese e interessi subito. Aprilo!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7918&d=10-12
João Eiras
2008-12-07 14:41:06 UTC
Permalink
IMO, anyone suggesting a Node.getElementById clearly does not know very
well how getElementById is supposed to work.
There are ways to transverse a DOM tree currently, either DOM properties
and methods, XPath, selectors API and such.
Considering ids are required to be unique in the context of a single
document, implementations can, and do, implement id lookup using optimized
data structures like a hash table, which is much more performant than
doing transversal.
So if there is a special node in a document, add an id to it and get its
reference will be performant (ideally O(1)).

If the uniqueness requirement is removed, then getElementById looses its
whole meaning and should actually be removed from the specification
entirely, else then we would need more bloat like getElementById or
getElementListById and whatever.

If you really need to get the element with id in a subtree, connected or
disconnected from the main tree, one can use selectors API, DOM
transversal, XPath, etc.

So, IMO the DOM spec is just fine. What is asked for Node.getElementById
is already supported by other APIs.
Calogero Alex Baldacchino
2008-12-07 19:07:24 UTC
Permalink
Post by João Eiras
IMO, anyone suggesting a Node.getElementById clearly does not know
very well how getElementById is supposed to work.
There are ways to transverse a DOM tree currently, either DOM
properties and methods, XPath, selectors API and such.
Considering ids are required to be unique in the context of a single
document, implementations can, and do, implement id lookup using
optimized data structures like a hash table, which is much more
performant than doing transversal.
So if there is a special node in a document, add an id to it and get
its reference will be performant (ideally O(1)).
Such a hash table cannot prevent at all the need of traversing the DOM
tree for the purpose of a _correct_ implementation of .getElementById. A
DOM tree is a live structure, so the hash table must be checked and
updated each time a node is removed AND each time a node is inserted,
for a couple of reasons, and such update may request some kind of tree
traversing (i.e. to compare nodes relative position). Actually,
getElementById is being defined as returning the _first_ element with a
matching ID, as a graceful degradation in case of duplicate IDs and to
give a better standard (= unique) definition of the expected behavior in
front of duplicate IDs, than what stated in DOM 3 Core (which leaves
such behavior unspecified -- it's said to be undefined -- and possibly
implementation or document specific); this means that, upon insertion of
a new element, this one might be the new 'first' element with a certain
id, so its order must be checked and the hash table updated accordingly.
When an element is removed, independently of the previous scenario, if
it was in the hash table it might be just removed from the table a well,
but such wouldn't work fine, because there might be a descendant, or an
otherwise following element with the same id: after the removal, such
element would pass from the 'illegal' state of being a duplicate-ID
element, to the 'legal' state of being the current element to be
returned by getElementById => the existence of such an element must be
checked and the hash table updated accordingly. If there are far more
insertions and/or removals of elements with the id attribute set, than
calls to getElementById, the advantage of a live hash table vs
traversing as needed can be quite lost; anyway, a traversal can be quite
fast, especially if the DOM structure is implemented as a balanced
binary tree (and I hope you don't wish to implement any kind of
non-binary tree as the base tree structure).
Post by João Eiras
If the uniqueness requirement is removed, then getElementById looses
its whole meaning and should actually be removed from the
specification entirely, else then we would need more bloat like
getElementById or getElementListById and whatever.
Do you thing that getElementsByTagName and getElementsByClassName are
bloaty and useless too? However, my point was, and is, another (I'm not
for Node.getElementById - nor I am strongly against it).
Post by João Eiras
If you really need to get the element with id in a subtree, connected
or disconnected from the main tree, one can use selectors API, DOM
transversal, XPath, etc.
Currently, the id uniqueness is defined such as constraining not only a
whole document, but also a disconnected subtree. Then, what API is such
constraint relevant for? If none, is it worth to declare such constraint
for disconnected subtrees? Or, is there any need for an API directly
handling IDs in disconnected subtrees?

In other words, what's being constrained by the id uniqueness in a
disconnected subtree? A disconnected subtree may be a subtree of another
document, different from the one currently handled by a script; in this
case, the id uniqueness is relevant for the actual document containing
the subtree (while any other document shouldn't be affected by
cross-document IDs clashes). Otherwise, it may be a subtree external to
any document, and in such case, perhaps, it might be out of scope for
HTML 5 documents specification. I'm starting to think that at most it
might be said, for disconnected subtrees outside any actual html
document but consisting of html elements, that any API dealing with
unique identifiers in a disconnected subtree of html elements must treat
the value of any such element's id attribute as the element default ID
(the id value uniqueness being a consequence of both its nature as ID
property and the nature of an API methods targeting an element ID
property, but not imposed by the specifications, since currently there
is no such method in the scope of HTML 5 DOM). As a consequence, the id
value uniqueness might be in scope for a DOM Core specification
explicitly willing to handle ID properties in a disconnected (and
'document-less') subtree of Elements, just because the id value
represent (at least) the first attribute of an HTML element to be
evaluated looking for an ID property.

Regard, Alex.


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Check-up finanziario di Intesa Sanpaolo. Prenotalo subito online, è gratis e senza impegno.
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8437&d=7-12
Maciej Stachowiak
2008-12-05 18:25:38 UTC
Permalink
Post by Aaron Leventhal
How about node.getElementByIdInSubtree?
In other cases where a getElement[s]By method is available on both
Document and other nodes, it has the same name in both cases
(getElementsByTagName, getElementsByClassName).

Regards,
Maciej
Post by Aaron Leventhal
On Tue, Dec 2, 2008 at 10:39 AM, Aaron
Maybe there is a deeper problem if copy& paste doesn't work right because
of IDs?
Or maybe there should be a node.getDescendantById() method?
maybe, but not with that name.
Results 1 - 10 of about 4,480,000 for Descendent [definition]. (0.22 seconds)
Results 1 - 10 of about 8,370,000 for Descendant [definition]. (0.41 seconds)
the wikipedia links are confusing enough
http://en.wiktionary.org/wiki/descendent
which has an also link to http://en.wiktionary.org/wiki/descendant
which has a 'US' audio file
So the web says that '-dant' is favored 2:1 over '-dent', which is a
fairly bad margin considering the spelling errors we've seen in
html/http.
I'd sooner see Node.getElementById and risk the confusion of it
returning fewer nodes than Document.getElementById.
Henri Sivonen
2008-12-06 06:55:22 UTC
Permalink
Post by Aaron Leventhal
How about node.getElementByIdInSubtree?
It's not sufficient to get an element in a subtree. What's needed is
getting a cell in the same table--filtering out nested tables.
--
Henri Sivonen
hsivonen-***@public.gmane.org
http://hsivonen.iki.fi/
Aaron Leventhal
2008-12-08 10:39:23 UTC
Permalink
IMO it's not worth all the extra code and confusion to write a special
table (but not inner table) ID getter.

- Aaron
Post by Henri Sivonen
Post by Aaron Leventhal
How about node.getElementByIdInSubtree?
It's not sufficient to get an element in a subtree. What's needed is
getting a cell in the same table--filtering out nested tables.
Ian Hickson
2008-12-25 11:35:13 UTC
Permalink
Post by Aaron Leventhal
Maybe there is a deeper problem if copy & paste doesn't work right
because of IDs?
Or maybe there should be a node.getDescendantById() method?
I haven't done anything with the feedback on this thread (not quoted),
because it is unclear what the use cases are, and because it is really out
of scope for HTML5.

I would have recommended bringing this up in the context of the Web DOM
Core work instead, if there are use cases of relevance, but since Simon
already replied on this thread, that seems moot also.

Cheers,
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Loading...