Closed Bug 288513 Opened 20 years ago Closed 13 years ago

add support for DOM 3 Attr.isId and setIdAttribute*

Categories

(Core :: DOM: Core & HTML, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: smaug, Assigned: smaug)

References

()

Details

Attachments

(1 file, 1 obsolete file)

(In reply to comment #1)
> Why?  How?

This is related to Bug 258238. If someone wants to implement something like
X+V, we should support namespaced ID attributes. Also Bug 275196 is relevant.

And don't we want to support DOM 3 Core?

The current idea is to set an ID flag to the nsDOMAttribute, 
there should be some spare bits. Of course Bug 235512 should be fixed first.

The W3C REC for elements shows setIdAttribute, setIdAttributeNS, and setIdAttributeNode -- nothing about getIdAttribute*.  What getters are you referring to?
oops, it should be Attr.isId.
Summary: add support for DOM 3 getIdAttribute* / setIdAttribute* → add support for DOM 3 Attr.isId and setIdAttribute*
Okay, that makes more sense.  I was about to file a bug for Attr.isId.

To support "mutation-resistant" XPath generators that don't happily live in content (aka "external parties"), they need to know if an attribute attached to an element is an ID-type attribute.

To implement this, we need interfaces for nsIDOM3Attr and nsIDOM3TypeInfo (the latter so we don't break idl).
Attached patch Implement nsIDOM3Attr::IsId() (obsolete) — Splinter Review
This patch adds nsIDOM3Attr and nsIDOM3TypeInfo from W3C DOM Level 3 Core (as nsIDOMAttr is frozen), and leaves schemaTypeInfo under NS_ERROR_NOT_IMPLEMENTED.

Tested on http://www.mozilla.org/projects/seamonkey/start/ :
document.body.attributes[0].nodeName == "class"
document.body.attributes[0].isId == false
document.body.attributes[1].nodeName == "id"
document.body.attributes[1].isId == true
Attachment #209657 - Flags: superreview?(jst)
Attachment #209657 - Flags: review?(jst)
Comment on attachment 209657 [details] [diff] [review]
Implement nsIDOM3Attr::IsId()

- In nsDOMAttribute::GetIsId(PRBool* aReturn):

+  nsAutoString name;
+  GetName(name);
+
+  *aReturn = idAtom->Equals(name);

This will make attributes in a namespace whose name happen to match the id attribute name ('id') also appear to be id's, even if they're not. The check here needs to be:

  *aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);

This will do the right thing, since for now we don't support having ID's in a namespace (and this is faster and less code too, e.g. no string).

r+sr=jst with that fixed.

This obviously only fixes part of this bug (the easy part), the other part requires some non-trivial getElementById() plumbing changes to get right.
Attachment #209657 - Flags: superreview?(jst)
Attachment #209657 - Flags: superreview+
Attachment #209657 - Flags: review?(jst)
Attachment #209657 - Flags: review+
Checked in that patch.
Comment on attachment 209796 [details] [diff] [review]
Updated IsId() patch to jst's comments.

+#include "nsIDOM3TypeInfo.idl"

why not forward-declare this, to avoid unnecessary includes and speed up compilation time (a little bit at least)?
Comment on attachment 209796 [details] [diff] [review]
Updated IsId() patch to jst's comments.

I believe this patch to be relatively safe for Fx2/SM1.5; it simply implements nsIDOM3Attr::IsId() for attribute nodes.

The patch has been on the trunk for a couple of weeks.
Attachment #209796 - Flags: branch-1.8.1?(jst)
Attachment #209796 - Flags: approval-branch-1.8.1?(jst) → approval-branch-1.8.1+
Depends on: 275196
QA Contact: ian → general
Blocks: 212218
This functionality is removed in DOM4.
Awesome
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: