Opened 13 years ago
Closed 12 years ago
#7379 closed enhancement (wontfix)
[patch][cla] first, last methods on NodeList
Reported by: | Sam Foster | Owned by: | dante |
---|---|---|---|
Priority: | low | Milestone: | future |
Component: | Dojox | Version: | 1.1.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
This is mostly sugar, but I find a frequent pattern is wanting to use dojo.query to apply a function to the first/last element matching some css selector. But without a guarantee that the query will match you have to check the nodelist length before accessing properties on the first item - a pain.
Attachments (1)
Change History (6)
Changed 13 years ago by
Attachment: | nodelist-first.patch added |
---|
comment:1 Changed 13 years ago by
I've got the first/last methods returning the NodeList?, so you could have e.g.:
dojo.query(".foo").first(function(n){ something... }).last(function(n) { something else }).etc...
So, its not overlapping with Nodelist.at(), nor is it the same as dojo.query("whatever:first-child"). The value I'm trying to add here is to avoid this:
/* get my element */ var nodes = dojo.query(".some > query"); if(nodes.length) { doSomething(nodes[0]); }
Its admittedly of marginal value, but its also next to no code, and I think makes for more fluid (user) code.
comment:2 Changed 12 years ago by
Cc: | dante added |
---|---|
Milestone: | tbd → 1.3 |
Summary: | first, last methods on NodeList → [patch][cla] first, last methods on NodeList |
comment:3 Changed 12 years ago by
Cc: | dante removed |
---|---|
Owner: | changed from Adam Peller to dante |
Pete, this one should probably belong to you...
comment:4 Changed 12 years ago by
Milestone: | 1.3 → future |
---|---|
Priority: | normal → low |
Status: | new → assigned |
so I'd love to see the ext-dojo namespace exist and be fun, but it's not practical at the moment. I'm going to put these minimal sized functions in plugd and doc them as time permits, and give them that clear migration path into dojo should the api be agreed upon. moving to 'future' for now, but just means I'll close when the code is in plugd and more prepared for merging.
comment:5 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
added to plugd r26. closing this ticket wontfix. We can decide later if any of base plugd code should be promoted and doc at leisure this way. (all plugd stuff is CLA'd to foundation)
[PATCH] [CLA] adds a dojo-ext top-level dir to dojox, and a Nodelist.js which defines a first, last method