[Pkg-javascript-commits] [dojo] 58/87: Backport [29124], [27952], and [27961] to 1.7. According to the original changesets, this fixes #14877, #14876, #10651, #11189. !strict
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.7.5
in repository dojo.
commit d5b2485f7b1af17153fcbca6970441ac70aa51aa
Author: Colin Snover <github.com at zetafleet.com>
Date: Fri Nov 23 22:36:21 2012 +0000
Backport [29124], [27952], and [27961] to 1.7. According to the original changesets, this fixes #14877, #14876, #10651, #11189. !strict
git-svn-id: http://svn.dojotoolkit.org/src/branches/1.7/dojo@30033 560b804f-0ae3-0310-86f3-f6aa0a117693
---
selector/acme.js | 17 ++++++++++++++---
selector/lite.js | 28 ++++++++++++++--------------
2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/selector/acme.js b/selector/acme.js
index d90dc72..7731a58 100644
--- a/selector/acme.js
+++ b/selector/acme.js
@@ -309,6 +309,12 @@ define(["../_base/kernel", "../has", "../dom", "../_base/sniff", "../_base/array
_cp.matchFor = cmf.slice(1, -1);
}
}
+ // remove backslash escapes from an attribute match, since DOM
+ // querying will get attribute values without backslashes
+ if(_cp.matchFor){
+ _cp.matchFor = _cp.matchFor.replace(/\\/g, "");
+ }
+
// end the attribute by adding it to the list of attributes.
currentPart.attrs.push(_cp);
_cp = null; // necessary?
@@ -1103,13 +1109,18 @@ define(["../_base/kernel", "../has", "../dom", "../_base/sniff", "../_base/array
var infixSpaceFunc = function(match, pre, ch, post){
return ch ? (pre ? pre + " " : "") + ch + (post ? " " + post : "") : /*n+3*/ match;
};
-
+
+ //Don't apply the infixSpaceRe to attribute value selectors
+ var attRe = /([^[]*)([^\]]*])?/g;
+ var attFunc = function(match, nonAtt, att) {
+ return nonAtt.replace(infixSpaceRe, infixSpaceFunc) + (att||"");
+ };
var getQueryFunc = function(query, forceDOM){
//Normalize query. The CSS3 selectors spec allows for omitting spaces around
//infix operators, >, ~ and +
//Do the work here since detection for spaces is used as a simple "not use QSA"
//test below.
- query = query.replace(infixSpaceRe, infixSpaceFunc);
+ query = query.replace(attRe, attFunc);
if(qsaAvail){
// if we've got a cached variant and we think we can do it, run it!
@@ -1192,7 +1203,7 @@ define(["../_base/kernel", "../has", "../dom", "../_base/sniff", "../_base/array
}
}else{
// DOM branch
- var parts = query.split(/\s*,\s*/);
+ var parts = query.match(/([^\s,](?:"(?:\\.|[^"])+"|'(?:\\.|[^'])+'|[^,])*)/g);
return _queryFuncCacheDOM[query] = ((parts.length < 2) ?
// if not a compound query (e.g., ".foo, .bar"), cache and return a dispatcher
getStepQueryFunc(query) :
diff --git a/selector/lite.js b/selector/lite.js
index e9d1b5e..55c149f 100644
--- a/selector/lite.js
+++ b/selector/lite.js
@@ -6,6 +6,7 @@ define(["../has", "../_base/kernel"], function(has, dojo){
var testDiv = document.createElement("div");
var matchesSelector = testDiv.matchesSelector || testDiv.webkitMatchesSelector || testDiv.mozMatchesSelector || testDiv.msMatchesSelector || testDiv.oMatchesSelector; // IE9, WebKit, Firefox have this, but not Opera yet
var querySelectorAll = testDiv.querySelectorAll;
+var unionSplit = /([^\s,](?:"(?:\\.|[^"])+"|'(?:\\.|[^'])+'|[^,])*)/g;
has.add("dom-matches-selector", !!matchesSelector);
has.add("dom-qsa", !!querySelectorAll);
@@ -106,7 +107,7 @@ var useRoot = function(context, query, method){
context = context.parentNode;
}
- var selectors = query.split(/\s*,\s*/);
+ var selectors = query.match(unionSplit);
for(var i = 0; i < selectors.length; i++){
selectors[i] = "[id='" + nid + "'] " + selectors[i];
}
@@ -161,10 +162,12 @@ if(!has("dom-matches-selector")){
}
};
function attr(name, value, type){
- if(value.match(/['"]/)){
- // it is quoted, do an eval to parse the string (CSS and JS parsing are close enough)
- value = eval(value);
+ var firstChar = value.charAt(0);
+ if(firstChar == '"' || firstChar == "'"){
+ // it is quoted, remove the quotes
+ value = value.slice(1, -1);
}
+ value = value.replace(/\\/g,'');
var comparator = attrComparators[type || ""];
return function(node){
var attrValue = node.getAttribute(name);
@@ -202,14 +205,9 @@ if(!has("dom-matches-selector")){
if(!matcher){
// create a matcher function for the given selector
// parse the selectors
- if(selector.replace(/(?:\s*([> ])\s*)|(\.)?([\w-]+)|\[([\w-]+)\s*(.?=)?\s*([^\]]*)\]/g, function(t, combinator, type, value, attrName, attrType, attrValue){
+ if(selector.replace(/(?:\s*([> ])\s*)|(#|\.)?((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(.?=)?\s*("(?:\\.|[^"])+"|'(?:\\.|[^'])+'|(?:\\.|[^\]])*)\s*\]/g, function(t, combinator, type, value, attrName, attrType, attrValue){
if(value){
- if(type == "."){
- matcher = and(matcher, className(value));
- }
- else{
- matcher = and(matcher, tag(value));
- }
+ matcher = and(matcher, selectorTypes[type || ""](value.replace(/\\/g, '')));
}
else if(combinator){
matcher = (combinator == " " ? ancestor : parent)(matcher);
@@ -234,13 +232,15 @@ if(!has("dom-matches-selector")){
if(!has("dom-qsa")){
var combine = function(selector, root){
// combined queries
- selector = selector.split(/\s*,\s*/);
+ var selectors = selector.match(unionSplit);
var indexed = [];
// add all results and keep unique ones, this only runs in IE, so we take advantage
// of known IE features, particularly sourceIndex which is unique and allows us to
// order the results
- for(var i = 0; i < selector.length; i++){
- var results = liteEngine(selector[i], root);
+ for(var i = 0; i < selectors.length; i++){
+ selector = new String(selectors[i].replace(/\s*$/,''));
+ selector.indexOf = escape; // keep it from recursively entering combine
+ var results = liteEngine(selector, root);
for(var j = 0, l = results.length; j < l; j++){
var node = results[j];
indexed[node.sourceIndex] = node;
--
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