[Pkg-javascript-commits] [dojo] 31/32: Use per element determination of children vs childNodes, fixes #12488 !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:10 UTC 2014


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

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

commit c67ea3e7a6463c8d5479b0c88007cd2c0c86443c
Author: Colin Snover <github.com at zetafleet.com>
Date:   Thu Aug 22 00:11:11 2013 +0000

    Use per element determination of children vs childNodes, fixes #12488 !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@25510 560b804f-0ae3-0310-86f3-f6aa0a117693
    
    (cherry picked from commit fc262d0d589c490cdd671791f1546a4665ed69c6)
---
 _base/query.js         | 9 ++-------
 tests/_base/query.html | 5 +++--
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/_base/query.js b/_base/query.js
index e053022..54edbe0 100644
--- a/_base/query.js
+++ b/_base/query.js
@@ -63,11 +63,6 @@ var defineQuery= function(d){
 	////////////////////////////////////////////////////////////////////////
 
 
-	// on browsers that support the "children" collection we can avoid a lot of
-	// iteration on chaff (non-element) nodes.
-	// why.
-	var childNodesName = !!getDoc().firstChild["children"] ? "children" : "childNodes";
-
 	var specials = ">~+";
 
 	// global thunk to determine whether we should treat the current query as
@@ -512,7 +507,7 @@ var defineQuery= function(d){
 	var getNodeIndex = function(node){
 		var root = node.parentNode;
 		var i = 0,
-			tret = root[childNodesName],
+			tret = root.children || root.childNodes,
 			ci = (node["_i"]||-1),
 			cl = (root["_l"]||-1);
 
@@ -793,7 +788,7 @@ var defineQuery= function(d){
 		filterFunc = filterFunc||yesman;
 		return function(root, ret, bag){
 			// get an array of child elements, skipping text and comment nodes
-			var te, x = 0, tret = root[childNodesName];
+			var te, x = 0, tret = root.children || root.childNodes;
 			while(te = tret[x++]){
 				if(
 					_simpleNodeTest(te) &&
diff --git a/tests/_base/query.html b/tests/_base/query.html
index f728a20..c930495 100644
--- a/tests/_base/query.html
+++ b/tests/_base/query.html
@@ -250,8 +250,8 @@
 						function xml_attrs(){
 							var doc = createDocument([
 								"<ResultSet>",
-									"<RESULT thinger='blah'>Two</RESULT>",
-									"<RESULT thinger='gadzooks'>Two</RESULT>",
+									"<RESULT thinger='blah'>ONE</RESULT>",
+									"<RESULT thinger='gadzooks'><CHILD>Two</CHILD></RESULT>",
 								"</ResultSet>"
 							].join(""));
 							var de = doc.documentElement;
@@ -260,6 +260,7 @@
 							doh.is(0, dojo.query("RESULT[THINGER]", de).length, "result elements with attrs (wrong)");
 							doh.is(2, dojo.query("RESULT[thinger]", de).length, "result elements with attrs");
 							doh.is(1, dojo.query("RESULT[thinger=blah]", de).length, "result elements with attr value");
+							doh.is(1, dojo.query("RESULT > CHILD", de).length, "Using child operator");
 						},
 						function sort(){
 							var i = dojo.query("div");

-- 
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