Closed Bug 218210 Opened 21 years ago Closed 21 years ago

find nodes does not work when searching for attribute

Categories

(Other Applications :: DOM Inspector, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jochen.mader, Assigned: db48x)

References

()

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624

when using the "find nodes" dialog in DOM Inspector to find a node by attribute
name + value, the "Find" button appears to do nothing.

However, the JavaScript Console displays an error: 
Error: aWalker.currentNode.getAttribute is not a function
Source File: chrome://inspector/content/viewers/dom/dom.js
Line: 560

B.T.W, already at DOM Inspector startup, the JavaScript Console displays:
Error: uncaught exception: [Exception... "Invalid ClassID or ContractID" 
nsresult: "0x80570017 (NS_ERROR_XPC_BAD_CID)"  location: "JS frame ::
chrome://inspector/content/jsutil/system/file.js :: <TOP_LEVEL> :: line 119" 
data: no]

Reproducible: Always

Steps to Reproduce:
1. Open JavaScript Console
2. Open DOM Inspector
3. Load any URL
4. Open "Find Nodes" dialog (Search -> Find Nodes...)
5. Select Search by Attr
6. Enter some attribute name + value
7. Click "Find"

Actual Results:  
Nothing visible in DOM Inspector, but JavaScript Console displays error.

Expected Results:  
Show a matching node, or tell me there is no matching node.
Can be fixed by inserting a pair of ():
Change

  doFindElementsByAttr: function(aWalker)
  {
    return aWalker.currentNode 
           && aWalker.currentNode.nodeType == Node.ELEMENT_NODE
           && this.mFindParams[1] == ""
              ? aWalker.currentNode.hasAttribute(this.mFindParams[0])
              : aWalker.currentNode.getAttribute(this.mFindParams[0]) ==
this.mFindParams[1];
  },

to

  doFindElementsByAttr: function(aWalker)
  {
    return aWalker.currentNode 
           && aWalker.currentNode.nodeType == Node.ELEMENT_NODE
           && (this.mFindParams[1] == ""
              ? aWalker.currentNode.hasAttribute(this.mFindParams[0])
              : aWalker.currentNode.getAttribute(this.mFindParams[0]) ==
this.mFindParams[1]);
  },

in dom.js (inspector.jar).

However, I propose that either this function is changed to test for substring
instead of equality or (better) that the Find Nodes dialog is extended so that
one can optionally search for substrings - especially when searching for attributes.
Mass re-assigning bugs to dom.inspector@extensions.bugs
Assignee: caillon → dom.inspector
*** Bug 233202 has been marked as a duplicate of this bug. ***
Attached patch fix (obsolete) — Splinter Review
needs (), just like Jochen said.
Assignee: dom-inspector → db48x
Status: UNCONFIRMED → ASSIGNED
Attachment #141182 - Flags: review?(timeless)
Attachment #141182 - Attachment is obsolete: true
Attachment #141183 - Flags: review?(timeless)
Attachment #141182 - Flags: review?(timeless)
Attachment #141183 - Flags: superreview?(bzbarsky)
Attachment #141183 - Flags: review?(timeless)
Attachment #141183 - Flags: review+
Comment on attachment 141183 [details] [diff] [review]
fix, also make searches case insensitive and match against substrings

Please do not make id matches case-insensitive.   In fact, don't make the other
matches case-insensitive either, for XML documents.  Other than that,
sr=bzbarsky.
Attachment #141183 - Flags: superreview?(bzbarsky) → superreview+
Do you mind if I ask why? This is a convenience feature, not something that has
to meet a w3c spec. Plus I think it'd be inconvenient to find out what kind of
document we're searching, and also rather inconvenient for it to be
case-sensitive sometimes but not others.
fix checked in
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Product: Core → Other Applications
QA Contact: timeless → dom-inspector
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: