hasOwnProperty should be called directly from prototype
Closed this issue · 2 comments
alexandrosm commented
While trying out harp.js, I fell onto this issue:
Since the message is pretty tell-tale, a google led me to this: http://www.2ality.com/2012/01/objects-as-maps.html
Without knowing too much about the terraformer codebase, I modified isEmpty in terraform/lib/helpers/raw.js to be as follows:
var isEmpty = function(obj) {
for(var prop in obj) {
if(Object.prototype.hasOwnProperty.call(obj,prop))
return false;
}
return true;
}
This caused the error to change into something more informative. The change I made should not have changed the behaviour, but my form is more resistant to problems, so I'm letting you guys know in case you want to correct it throughout your codebase.
kennethormandy commented
@alexandrosm I think you might want https://github.com/sintaxi/terraform :) Thanks for the additional details.
alexandrosm commented
Terribly sorry, so confused.