diff --git a/mustache.js b/mustache.js index 602d7b3..67c222d 100644 --- a/mustache.js +++ b/mustache.js @@ -356,7 +356,7 @@ var cache = this.cache; var value; - if (name in cache) { + if (cache.hasOwnProperty(name)) { value = cache[name]; } else { var context = this, names, index, lookupHit = false; diff --git a/test/_files/avoids_obj_prototype_in_view_cache.js b/test/_files/avoids_obj_prototype_in_view_cache.js new file mode 100644 index 0000000..2ab58cd --- /dev/null +++ b/test/_files/avoids_obj_prototype_in_view_cache.js @@ -0,0 +1,4 @@ +({ + valueOf: 'Avoids methods', + watch: 'in Object.prototype' +}) diff --git a/test/_files/avoids_obj_prototype_in_view_cache.mustache b/test/_files/avoids_obj_prototype_in_view_cache.mustache new file mode 100644 index 0000000..f6e469b --- /dev/null +++ b/test/_files/avoids_obj_prototype_in_view_cache.mustache @@ -0,0 +1 @@ +{{valueOf}} {{watch}} \ No newline at end of file diff --git a/test/_files/avoids_obj_prototype_in_view_cache.txt b/test/_files/avoids_obj_prototype_in_view_cache.txt new file mode 100644 index 0000000..2621d99 --- /dev/null +++ b/test/_files/avoids_obj_prototype_in_view_cache.txt @@ -0,0 +1 @@ +Avoids methods in Object.prototype \ No newline at end of file