[Pkg-javascript-commits] [dojo] 05/07: back-porting fix for query() DOM branch matching too many nodes in descendant selectors. Fixes #9071. !strict

David Prévot taffit at moszumanska.debian.org
Mon May 11 20:12:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.3.1
in repository dojo.

commit ee1781d77112b1402cc29cef15aa927b96b0f3f4
Author: Alex Russell <slightlyoff at chromium.org>
Date:   Wed Apr 29 06:35:38 2009 +0000

    back-porting fix for query() DOM branch matching too many nodes in descendant selectors. Fixes #9071. !strict
    
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.3/dojo@17461 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 _base/query.js         | 18 ++++++++++++------
 tests/_base/query.html | 21 ++++++++++++++++++++-
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/_base/query.js b/_base/query.js
index 3ef4305..9efdc6b 100644
--- a/_base/query.js
+++ b/_base/query.js
@@ -1017,22 +1017,26 @@ if(typeof dojo != "undefined"){
 				// ignore class and ID filters since we will have handled both
 				filterFunc = getSimpleFilterFunc(query, { el: 1, classes: 1, id: 1 });
 				var classesString = query.classes.join(" ");
-				retFunc = function(root, arr){
+				retFunc = function(root, arr, bag){
 					var ret = getArr(0, arr), te, x=0;
 					var tret = root.getElementsByClassName(classesString);
 					while((te = tret[x++])){
-						if(filterFunc(te, root)){ ret.push(te); }
+						if(filterFunc(te, root) && _isUnique(te, bag)){
+							ret.push(te);
+						}
 					}
 					return ret;
 				};
 
 			}else if(!wildcardTag && !query.loops){
 				// it's tag only. Fast-path it.
-				retFunc = function(root, arr){
+				retFunc = function(root, arr, bag){
 					var ret = getArr(0, arr), te, x=0;
 					var tret = root.getElementsByTagName(query.getTag());
 					while((te = tret[x++])){
-						ret.push(te);
+						if(_isUnique(te, bag)){
+							ret.push(te);
+						}
 					}
 					return ret;
 				};
@@ -1042,12 +1046,14 @@ if(typeof dojo != "undefined"){
 				//		to have a tag selector, even if it's just "*" so we query
 				//		by that and filter
 				filterFunc = getSimpleFilterFunc(query, { el: 1, tag: 1, id: 1 });
-				retFunc = function(root, arr){
+				retFunc = function(root, arr, bag){
 					var ret = getArr(0, arr), te, x=0;
 					// we use getTag() to avoid case sensitivity issues
 					var tret = root.getElementsByTagName(query.getTag());
 					while((te = tret[x++])){
-						if(filterFunc(te, root)){ ret.push(te); }
+						if(filterFunc(te, root) && _isUnique(te, bag)){
+							ret.push(te);
+						}
 					}
 					return ret;
 				};
diff --git a/tests/_base/query.html b/tests/_base/query.html
index 703c28a..ddda44c 100644
--- a/tests/_base/query.html
+++ b/tests/_base/query.html
@@ -105,6 +105,17 @@
 						"doh.is(3, dojo.query('> *', 'container').length);",
 						"doh.is('passed', dojo.query('#bug')[0].value);",
 
+						// bug 9071
+						"doh.is(2, (dojo.query('a', 't4')).length);",
+						"doh.is(2, (dojo.query('p a', 't4')).length);",
+						"doh.is(2, (dojo.query('div p', 't4')).length);",
+						"doh.is(2, (dojo.query('div p a', 't4')).length);",
+						"doh.is(2, (dojo.query('.subA', 't4')).length);",
+						"doh.is(2, (dojo.query('.subP .subA', 't4')).length);",
+						"doh.is(2, (dojo.query('.subDiv .subP', 't4')).length);",
+						"doh.is(2, (dojo.query('.subDiv .subP .subA', 't4')).length);",
+
+
 						// failed scope arg
 						"doh.is(0, (dojo.query('*', 'thinger')).length);",
 						"doh.is(0, (dojo.query('div#foo').length));",
@@ -239,7 +250,7 @@
 				<span></span>
 			</div>
 			<h3>h3</h3>
-			<h3 class="baz" title="thud">h3</h3>
+			<h3 class="baz foobar" title="thud">h3</h3>
 			<span class="fooBar baz foo"></span>
 			<span foo="bar"></span>
 			<span foo="baz bar thud"></span>
@@ -263,6 +274,14 @@
 			<input type="radio" name="radio" id="radio3" value="blah">
 		</div>
 		<iframe id="t3" name="t3" src="../../resources/blank.html"></iframe>
+		<div id="t4">
+			<div id="one" class="subDiv">
+				<p class="one subP"><a class="subA">one</a></p>
+				<div id="two" class="subDiv">
+					<p class="two subP"><a class="subA">two</a></p>
+				</div>
+			</div>
+		</div>
 	</body>
 </html>
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list