Skip to content

Commit

Permalink
fix(serializer): When we recurse, be sure to bind this/self so that i…
Browse files Browse the repository at this point in the history
…t is properly defined in the next step.
  • Loading branch information
Justin Gallardo committed Oct 3, 2014
1 parent 770c9b2 commit e511e4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/serializer.js
Expand Up @@ -230,7 +230,7 @@ Swiz.prototype.buildObjectSync = function(obj) {
}
else if (obj instanceof Array) {
// Recurse onto every element of an array
return obj.map(self.buildObjectSync);
return obj.map(self.buildObjectSync.bind(this));
}
else if (obj instanceof Object && obj.getSerializerType) {
// Recurse onto each property named in the definition
Expand Down Expand Up @@ -266,7 +266,7 @@ Swiz.prototype.buildObjectSync = function(obj) {
}
}

result[dst] = self.buildObjectSync(obj[src]);
result[dst] = self.buildObjectSync.bind(self)(obj[src]);
});
return result;
}
Expand All @@ -279,7 +279,7 @@ Swiz.prototype.buildObjectSync = function(obj) {
if (!obj.hasOwnProperty(key)) {
return;
}
result[key] = self.buildObjectSync(obj[key]);
result[key] = self.buildObjectSync.bind(self)(obj[key]);
});
return result;
}
Expand Down

0 comments on commit e511e4d

Please sign in to comment.