Diffstat (limited to 'frontend/gamma/js/MochiKit/Selector.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/Selector.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/frontend/gamma/js/MochiKit/Selector.js b/frontend/gamma/js/MochiKit/Selector.js index 6aec892..3187fe9 100644 --- a/frontend/gamma/js/MochiKit/Selector.js +++ b/frontend/gamma/js/MochiKit/Selector.js @@ -5,13 +5,13 @@ MochiKit.Selector 1.5 See <http://mochikit.com/> for documentation, downloads, license, etc. (c) 2005 Bob Ippolito and others. All rights Reserved. ***/ -MochiKit.Base._module('Selector', '1.5', ['Base', 'DOM', 'Iter']); +MochiKit.Base.module(MochiKit, 'Selector', '1.5', ['Base', 'DOM', 'Iter']); MochiKit.Selector.Selector = function (expression) { this.params = {classNames: [], pseudoClassNames: []}; this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); this.parseExpression(); this.compileMatcher(); @@ -124,14 +124,14 @@ MochiKit.Selector.Selector.prototype = { a = 2; b = 1; } else if (match[0] == 'even') { a = 2; b = 0; } else { - a = match[2] && parseInt(match) || null; - b = parseInt(match[3]); + a = match[2] && parseInt(match, 10) || null; + b = parseInt(match[3], 10); } conditions.push('this.nthChild(element,' + a + ',' + b + ',' + !!pseudoClass.match('^nth-last') // Reverse + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName + ')'); break; @@ -164,23 +164,23 @@ MochiKit.Selector.Selector.prototype = { break; case 'checked': conditions.push('(this.isUIElement(element) && element.checked === true)'); break; case 'not': var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); - conditions.push('!( ' + subselector.buildMatchExpression() + ')') + conditions.push('!( ' + subselector.buildMatchExpression() + ')'); break; } } } if (clause = params.attributes) { MochiKit.Base.map(function (attribute) { var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; var splitValueBy = function (delimiter) { return value + '.split(' + repr(delimiter) + ')'; - } + }; conditions.push(value + ' != null'); switch (attribute.operator) { case '=': conditions.push(value + ' == ' + repr(attribute.value)); break; case '~=': @@ -349,12 +349,18 @@ MochiKit.Base.update(MochiKit.Selector, { res.push(arr[i]); } } return res; }; return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { + try { + var res = element.querySelectorAll(expression); + return Array.prototype.slice.call(res, 0); + } catch (ignore) { + // No querySelectorAll or extended expression syntax used + } var nextScope = ""; var reducer = function (results, expr) { var match = expr.match(/^[>+~]$/); if (match) { nextScope = match[0]; return results; |