cleaned up and optimized fix for #1354 (d91ccd4003
)
This commit is contained in:
parent
004f13f0fc
commit
2ac74356bd
15
lib/nodes.js
15
lib/nodes.js
|
@ -1728,22 +1728,21 @@
|
||||||
In.prototype.children = ['object', 'array'];
|
In.prototype.children = ['object', 'array'];
|
||||||
In.prototype.invert = NEGATE;
|
In.prototype.invert = NEGATE;
|
||||||
In.prototype.compileNode = function(o) {
|
In.prototype.compileNode = function(o) {
|
||||||
var isArray, obj, splat, _i, _len, _ref2;
|
var hasSplat, obj, _i, _len, _ref2;
|
||||||
isArray = this.array instanceof Value && this.array.isArray();
|
if (this.array instanceof Value && this.array.isArray()) {
|
||||||
if (isArray) {
|
|
||||||
_ref2 = this.array.base.objects;
|
_ref2 = this.array.base.objects;
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
obj = _ref2[_i];
|
obj = _ref2[_i];
|
||||||
if (obj instanceof Splat) {
|
if (obj instanceof Splat) {
|
||||||
splat = obj;
|
hasSplat = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!hasSplat) {
|
||||||
if (isArray && !splat) {
|
|
||||||
return this.compileOrTest(o);
|
return this.compileOrTest(o);
|
||||||
} else {
|
|
||||||
return this.compileLoopTest(o);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return this.compileLoopTest(o);
|
||||||
};
|
};
|
||||||
In.prototype.compileOrTest = function(o) {
|
In.prototype.compileOrTest = function(o) {
|
||||||
var cmp, cnj, i, item, ref, sub, tests, _ref2, _ref3;
|
var cmp, cnj, i, item, ref, sub, tests, _ref2, _ref3;
|
||||||
|
|
|
@ -1349,11 +1349,12 @@ exports.In = class In extends Base
|
||||||
invert: NEGATE
|
invert: NEGATE
|
||||||
|
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
isArray = @array instanceof Value and @array.isArray()
|
if @array instanceof Value and @array.isArray()
|
||||||
splat = obj for obj in @array.base.objects when obj instanceof Splat if isArray
|
for obj in @array.base.objects when obj instanceof Splat
|
||||||
if isArray and not splat
|
hasSplat = yes
|
||||||
@compileOrTest o
|
break
|
||||||
else
|
# `compileOrTest` only if we have an array literal with no splats
|
||||||
|
return @compileOrTest o unless hasSplat
|
||||||
@compileLoopTest o
|
@compileLoopTest o
|
||||||
|
|
||||||
compileOrTest: (o) ->
|
compileOrTest: (o) ->
|
||||||
|
|
Loading…
Reference in New Issue