From 81bea17aefb26859f825b9293c7c99192874806e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 8 Nov 2011 20:40:44 +0400 Subject: upgrade Dojo to 1.6.1 --- lib/dojo/NodeList-traverse.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'lib/dojo/NodeList-traverse.js') diff --git a/lib/dojo/NodeList-traverse.js b/lib/dojo/NodeList-traverse.js index b5314eed6..b6167ad0e 100644 --- a/lib/dojo/NodeList-traverse.js +++ b/lib/dojo/NodeList-traverse.js @@ -1,5 +1,5 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ @@ -9,6 +9,7 @@ if(!dojo._hasResource["dojo.NodeList-traverse"]){ //_hasResource checks added by dojo._hasResource["dojo.NodeList-traverse"] = true; dojo.provide("dojo.NodeList-traverse"); + /*===== dojo["NodeList-traverse"] = { // summary: Adds a chainable methods to dojo.query() / Nodelist instances for traversing the DOM @@ -28,18 +29,7 @@ dojo.extend(dojo.NodeList, { ary = ary.concat(items); } } - return ary; - }, - - _filterQueryResult: function(nodeList, query){ - // summmary: - // Replacement for dojo._filterQueryResult that does a full - // query. Slower, but allows for more types of queries. - var filter = dojo.filter(nodeList, function(node){ - return dojo.query(query, node.parentNode).indexOf(node) != -1; - }); - var result = this._wrap(filter); - return result; + return ary; }, _getUniqueAsNodeList: function(nodes){ @@ -65,7 +55,7 @@ dojo.extend(dojo.NodeList, { // gets unique element nodes, filters them further // with an optional query and then calls _stash to track parent NodeList. var ary = this._getUniqueAsNodeList(nodes); - ary = (query ? this._filterQueryResult(ary, query) : ary); + ary = (query ? dojo._filterQueryResult(ary, query) : ary); return ary._stash(this); //dojo.NodeList }, @@ -73,7 +63,7 @@ dojo.extend(dojo.NodeList, { // summary: // cycles over all the nodes and calls a callback // to collect nodes for a possible inclusion in a result. - // The callback will get two args: callback(node, ary), + // The callback will get two args: callback(node, ary), // where ary is the array being used to collect the nodes. return this._getUniqueNodeListWithParent(this._buildArrayFromCallback(callback), query); //dojo.NodeList }, @@ -109,7 +99,7 @@ dojo.extend(dojo.NodeList, { }); //dojo.NodeList }, - closest: function(/*String*/query){ + closest: function(/*String*/query, /*String|DOMNode?*/ root){ // summary: // Returns closest parent that matches query, including current node in this // dojo.NodeList if it matches the query. @@ -118,6 +108,8 @@ dojo.extend(dojo.NodeList, { // original dojo.NodeList. // query: // a CSS selector. + // root: + // If specified, query is relative to "root" rather than document body. // returns: // dojo.NodeList, the closest parent that matches the query, including the current // node in this dojo.NodeList if it matches the query. @@ -133,13 +125,12 @@ dojo.extend(dojo.NodeList, { // Running this code: // | dojo.query(".red").closest(".container"); // returns the div with class "container". - var self = this; - return this._getRelatedUniqueNodes(query, function(node, ary){ + return this._getRelatedUniqueNodes(null, function(node, ary){ do{ - if(self._filterQueryResult([node], query).length){ + if(dojo._filterQueryResult([node], query, root).length){ return node; } - }while((node = node.parentNode) && node.nodeType == 1); + }while(node != root && (node = node.parentNode) && node.nodeType == 1); return null; //To make rhino strict checking happy. }); //dojo.NodeList }, @@ -461,7 +452,7 @@ dojo.extend(dojo.NodeList, { // | // Running this code: // | dojo.query(".blue").last(); - // returns the last div with class "blue", + // returns the last div with class "blue", return this._wrap((this.length ? [this[this.length - 1]] : []), this); //dojo.NodeList }, -- cgit v1.2.3