Opened 10 years ago

Closed 4 years ago

#9656 closed enhancement (patchwelcome)

NodeList-dom: add find() method

Reported by: Les Owned by: Kris Zyp
Priority: low Milestone: 1.13
Component: Query Version: 1.3.2
Keywords: NodeList Cc:
Blocked By: Blocking:

Description

NodeList? contains the following:

// FIXME: do we need this?
query: function(/*String*/ queryStr){
...

I'd say we need this, but please add the following one line in NodeList?-traverse to improve consistency with jQuery, which has the find() method.

find: dojo.NodeList.prototype.query,

Here's an example how I'd use the find() method:

dojo.query('#inputForm').find('input');

in addition to the current code:

dojo.query('#inputForm').query('input')

Change History (9)

comment:1 Changed 10 years ago by dante

I disagree we should have this alias in base. It belongs in the compat layer.

comment:2 Changed 10 years ago by Les

Enhancement suggestion for 2.0:

The query() method could be used to return the actual selector used to generate the NodeList? and the find() method would replace the current query() functionality.

Examples:

dojo.query('#inputForm').query(); // returns '#inputForm'
dojo.query(myForm).query(); // returns ''
new dojo.NodeList().query(); // returns ''
var nl = new dojo.NodeList();
nl.push(dojo.byId("someId"));
nl.query() // returns ''

Alternately, a new selector property (as in jQuery) could be added to NodeList?, e.g. dojo.query('#inputForm').selector; returns '#inputForm'

comment:3 Changed 10 years ago by dante

I like the idea of exposing the selector passed to dojo.query in the NodeList? returned. It would have to handle the case where a list returns a modified list, and that may get complicated but I've not thought about all the cases tbh. Against making it a function call or changing the API from query() to find() just for the sake of renaming, but 2.0 might be an option there.

comment:4 Changed 10 years ago by James Burke

Component: GeneralCore
Milestone: tbdfuture
Owner: changed from anonymous to James Burke

In what situations is knowing the selector after the fact helpful?

comment:5 Changed 10 years ago by Les

It would be helpful for debugging and learning. If I was using a Dojo method that returns a NodeList?, I’d like to know how this NodeList? was constructed. Inspecting the selector property in Firebug would give me an idea.

comment:6 Changed 7 years ago by bill

Component: CoreQuery
Milestone: future2.0
Owner: changed from James Burke to Kris Zyp
Status: newassigned

Assigning to Kris to decide to do for 2.0, or mark as wontfix.

comment:7 Changed 7 years ago by bill

Priority: highlow
Summary: NodeList-traverse add findNodeList-dom: add find() method
Type: defectenhancement

comment:8 Changed 4 years ago by dylan

Milestone: 2.01.12

Given that no one has shown interest in creating a patch in the past 5+ years, I'm closing this as patchwelcome.

comment:9 Changed 4 years ago by dylan

Resolution: patchwelcome
Status: assignedclosed
Note: See TracTickets for help on using tickets.