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 @@ -7,9 +7,9 @@ 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, ''); @@ -126,10 +126,10 @@ MochiKit.Selector.Selector.prototype = { } 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 @@ -166,9 +166,9 @@ MochiKit.Selector.Selector.prototype = { 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; } } } @@ -176,9 +176,9 @@ MochiKit.Selector.Selector.prototype = { 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)); @@ -351,8 +351,14 @@ MochiKit.Base.update(MochiKit.Selector, { } 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) { |