Skip to content

Commit

Permalink
Updating slick's version and making a clone of the parsed expression …
Browse files Browse the repository at this point in the history
…so we can change the cache and it will still work fine.
  • Loading branch information
fabiomcosta committed Oct 15, 2010
1 parent 7ea65fb commit 5fb3aed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/Element/Element.js
Expand Up @@ -436,7 +436,7 @@ Object.each(inserters, function(inserter, where){
var injectCombinator = function(expression, combinator){
if (!expression) return combinator;

expression = Slick.parse(expression);
expression = Object.clone(Slick.parse(expression));

var expressions = expression.expressions;
for (var i = expressions.length; i--;)
Expand Down
4 changes: 2 additions & 2 deletions Source/Slick/Slick.Finder.js
Expand Up @@ -614,11 +614,11 @@ var pseudos = {
return this['pseudo:nth-child'](node, '' + index + 1);
},

'even': function(node, argument){
'even': function(node){
return this['pseudo:nth-child'](node, '2n');
},

'odd': function(node, argument){
'odd': function(node){
return this['pseudo:nth-child'](node, '2n+1');
},

Expand Down
3 changes: 2 additions & 1 deletion Source/Slick/Slick.Parser.js
Expand Up @@ -27,9 +27,10 @@ var parse = function(expression, isReversed){
return parse(this.raw, true);
}};
separatorIndex = -1;
var cacheKey = expression;
while (expression != (expression = expression.replace(regexp, parser)));
parsed.length = parsed.expressions.length;
return currentCache[expression] = (reversed) ? reverse(parsed) : parsed;
return currentCache[cacheKey] = (reversed) ? reverse(parsed) : parsed;
};

var reverseCombinator = function(combinator){
Expand Down

0 comments on commit 5fb3aed

Please sign in to comment.