diff --git a/mustache.js b/mustache.js index 6ff90f2..4fab12e 100644 --- a/mustache.js +++ b/mustache.js @@ -380,13 +380,13 @@ **/ while (value != null && index < names.length) { if (index === names.length - 1 && value != null) - lookupHit = (typeof value === 'object') && - value.hasOwnProperty(names[index]); + lookupHit = (typeof value === 'object') && value[names[index]]; + value = value[names[index++]]; } } else if (context.view != null && typeof context.view === 'object') { value = context.view[name]; - lookupHit = context.view.hasOwnProperty(name); + lookupHit = context.view.hasOwnProperty(name) || Object.prototype[name] !== value; } if (lookupHit) diff --git a/test/_files/uses_props_from_view_prototype.js b/test/_files/uses_props_from_view_prototype.js new file mode 100644 index 0000000..5fff76a --- /dev/null +++ b/test/_files/uses_props_from_view_prototype.js @@ -0,0 +1,30 @@ +var Aaa = (function () { + function Aaa(x, y) { + this.x = x; + this._y = y; + } + Object.defineProperty(Aaa.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + this._y = value; + }, + enumerable: true, + configurable: true + }); + return Aaa; +})(); +var Bbb = (function () { + function Bbb() { + } + return Bbb; +})(); + +var b = new Bbb(); +b.item = new Aaa("0", "00"); +b.items = []; +b.items.push({ a: new Aaa("1", "2") }); +b.items.push({ a: new Aaa("3", "4") }); + +(b) diff --git a/test/_files/uses_props_from_view_prototype.mustache b/test/_files/uses_props_from_view_prototype.mustache new file mode 100644 index 0000000..874f0c9 --- /dev/null +++ b/test/_files/uses_props_from_view_prototype.mustache @@ -0,0 +1 @@ +[{{ item.x }};{{ item.y }}]||{{#items}}[{{ a.x }};{{ a.y }} {{#a}}{{y}}{{/a}}]{{/items}} \ No newline at end of file diff --git a/test/_files/uses_props_from_view_prototype.txt b/test/_files/uses_props_from_view_prototype.txt new file mode 100644 index 0000000..f416840 --- /dev/null +++ b/test/_files/uses_props_from_view_prototype.txt @@ -0,0 +1 @@ +[0;00]||[1;2 2][3;4 4] \ No newline at end of file