#11457 closed enhancement (fixed)
[patch] [cla] NodeList: efficient implementation of closest()
Reported by: | bill | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | Core | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
Enhance !Nodelist.closest() to run quickly for simple selectors, avoiding running dojo.query() on the whole document (for each element of NodeList). This is a prerequisite to implementing live() and delegate().
The base issue is:
- dojo._filterQueryResult() runs quickly but only handles simple selector, like ".foo"
- NodeList._filterQueryResult() can handle any query (like ".foo .bar") but runs slowly (worst case O(n) where n is the number of nodes in the document).
The two functions could be combined.
After fixing dojo._filterQueryResult() to handle any selector, NodeList.orphan() etc. will start to work for any selectors.
As per http://thread.gmane.org/gmane.comp.web.dojo.devel/12516/focus=12559.
Attachments (1)
Change History (6)
Changed 11 years ago by
Attachment: | filterQueryResult.patch added |
---|
comment:1 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 11 years ago by
Milestone: | tbd → 1.6 |
---|---|
Owner: | changed from anonymous to bill |
comment:3 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [22528]) Fix/enhance dojo._filterQueryResult(), NodeList.closest(), NodeList.orphan(), and NodeList.filter() to work on descendant selectors like "div > span", yet to work efficiently for simple selectors like ".foo". Fixes #11457, #11458 !strict.
Also, enhanced NodeList.closest() to take an optional root parameter (same as dojo.query()'s root parameter). If root is specified, the selector is relative to that node rather than the document root. This parameter will be useful for future NodeList.delegate(). Refs #11459.
comment:4 Changed 11 years ago by
comment:5 Changed 11 years ago by
(In [22537]) Make simple-filter check stricter, so that "> div" isn't classified as a simple filter. Also remove query argument from closest()'s call to _getRelatedUniqueNodes(), since it seems unnecessary (the filter has already been applied) and also since it won't work correctly without also passing in the root node that the query is relative to. Fixes #11457, #11458 !strict.
Patch looks good, feel free to apply it! If you would rather I apply it, I am happy to do so, but otherwise assigning to you for 1.6.