Permalink
Browse files

fix for function properties

  • Loading branch information...
substack committed Jan 7, 2012
1 parent 8da67a3 commit 6d570a19b45ad447bd7aa3737f7698a492448787
Showing with 20 additions and 16 deletions.
  1. +18 −15 index.js
  2. +2 −1 test/sources/assignment.js
View
@@ -69,22 +69,25 @@ Stack.prototype.compile = function (context, opts) {
stack.unshift(node);
var stack_ = stacks[ix] = stack.slice();
+ function wrap (f) {
+ if (typeof f !== 'function') return f;
+
+ var f_ = function () {
+ stack.splice(0);
+ stack.push.apply(stack, stack_);
+ if (f.apply) {
+ return f.apply(this, arguments);
+ }
+ else {
+ return apply(f, this, arguments);
+ }
+ };
+ for (var key in f) f_[key] = wrap(f[key]);
+ return f_;
+ }
+
for (var i = 0; i < args.length; i++) {
- var arg = args[i];
- if (typeof arg === 'function') {
- args[i] = (function (f) {
- return function () {
- stack.splice(0);
- stack.push.apply(stack, stack_);
- if (f.apply) {
- return f.apply(this, arguments);
- }
- else {
- return apply(f, this, arguments);
- }
- };
- })(arg);
- }
+ args[i] = wrap(args[i])
}
var res;
@@ -1,2 +1,3 @@
var b = false;
-var a = b && b.c || b.d
+var a = {};
+a.b = b && b.c || b.d

0 comments on commit 6d570a1

Please sign in to comment.