DOM attribute isId property (Attr::isId) returns undefined

NEW
Unassigned

Status

Other Applications
DOM Inspector
3 years ago
3 years ago

People

(Reporter: Peter B. Shalimoff, Unassigned, NeedInfo)

Tracking

Trunk
x86_64
Windows 7

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

3 years ago
Created attachment 8451297 [details]
dom_attr_isId_test.html

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 SeaMonkey/2.25 (Beta/Release)
Build ID: 20140318183706

Steps to reproduce:

Open the attached test page and click the Test button.



Actual results:

The isId attribute doesn't exist:
attr: 'id'
isId: exists: false, value=[undefined]: undefined

The result doesn't depend on the rendering mode (quirks/standards).

This breaks DOM Inspector's search by ID - see the doFindElementById() function in /chrome/inspector/content/inspector/viewers/dom/dom.js, line 938 (for version 2.0.15pre). As a workaround, you can use search by attribute, with the attribute name set to "id".


Expected results:

Comment 1

3 years ago
Created attachment 8451354 [details]
dom_attr_isId_test2.html

DOM Inspector Search by id works for me (See 865008). Also this modified test works for me.

Also see:
http://help.dottoro.com/ljrgussb.php
> The isId property does not work in XML documents, only in HTML documents.
> For a cross-browser solution, use the value of the name property instead.

http://help.dottoro.com/external/examples/ljrgussb/isId_1.htm

@Neil: perhaps we should do it the way dottoro does?

It's true however that we should really really ship a new DOM Inspector

@Iann weren't you going to release a new DOM Inspector and upload it to addons.mozilla?
Flags: needinfo?(neil)
Flags: needinfo?(iann_bugzilla)

Updated

3 years ago
Group: core-security
Status: UNCONFIRMED → NEW
Depends on: 865008
Ever confirmed: true

Comment 2

3 years ago
Removing accidental s-g bit.
Group: core-security

Comment 3

3 years ago
(In reply to Peter B. Shalimoff)
> This breaks DOM Inspector's search by ID - see the doFindElementById()
> function in /chrome/inspector/content/inspector/viewers/dom/dom.js, line 938
> (for version 2.0.15pre). As a workaround, you can use search by attribute,
> with the attribute name set to "id".
Flags: needinfo?(neil)

Comment 4

3 years ago
(Sorry for the accidental submit)

(In reply to Peter B. Shalimoff)
> This breaks DOM Inspector's search by ID - see the doFindElementById()
> function in /chrome/inspector/content/inspector/viewers/dom/dom.js, line 938
> (for version 2.0.15pre). As a workaround, you can use search by attribute,
> with the attribute name set to "id".

(In reply to Philip Chee)
> DOM Inspector Search by id works for me (See 865008). Also this modified
> test works for me.

DOM Inspector 2.0.14 does it the "old" way using isId. Current tip DOM Inspector includes the fix to bug 865008 and is therefore able to locate the elements correctly.

> perhaps we should do it the way dottoro does?

Enumerating the attributes and choosing the one named "id" is pointless, we simply go directly to getAttribute("id") which works well enough on all supported versions of Gecko.

Updated

3 years ago
Component: General → DOM Inspector
Product: SeaMonkey → Other Applications
Version: SeaMonkey 2.25 Branch → Trunk
(Reporter)

Comment 5

3 years ago
> Component: General → DOM Inspector

Undo this please. In case it's still unclear from the title, this bug is not about DOM Inspector (there's already bug 865008 for that), but about the browser itself, namely about the isId property not existing (returning undefined) for both HTML and XML documents, despite the documentation at MDN says it exists (https://developer.mozilla.org/en/docs/Web/API/Attr) and it's not in the deprecated list (https://developer.mozilla.org/en/docs/Web/API/Attr#Deprecated_properties_and_methods), and using it doesn't result in any deprecation warnings in the console - see my html test page.

Is the attribute removed? It exists in Attr.cpp (line 322 in http://dxr.mozilla.org/mozilla-central/source/content/base/src/Attr.cpp) and in nsIDOMAttr.idl (line 28 in http://dxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMAttr.idl), but doesn't exist in Attr.webidl (http://dxr.mozilla.org/mozilla-central/source/dom/webidl/Attr.webidl).
(Reporter)

Comment 6

3 years ago
Created attachment 8459119 [details]
dom_attr_isId_test.xml

A test XML document that demonstrates isId doesn't exist for XML either. Just use the code from the HTML test document (single line) in the address bar:
[code]
javascript:function test(){var a = document.getElementById('p').attributes[0];alert("attr: '" + a.nodeName + "'"+ "\nisId: exists: " + ("isId" in a) + ", value=[" + typeof(a.isId) + "]: " + a.isId);} test();
[/code]
You need to log in before you can comment on or make changes to this bug.