Explorar el Código

Bugfix for using values from view's context prototype.

Fixes #445
tags/v2.1.1
Phillip Johnsen hace 11 años
padre
commit
fc6d73b353
Se han modificado 4 ficheros con 35 adiciones y 3 borrados
  1. +3
    -3
      mustache.js
  2. +30
    -0
      test/_files/uses_props_from_view_prototype.js
  3. +1
    -0
      test/_files/uses_props_from_view_prototype.mustache
  4. +1
    -0
      test/_files/uses_props_from_view_prototype.txt

+ 3
- 3
mustache.js Ver fichero

@@ -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)


+ 30
- 0
test/_files/uses_props_from_view_prototype.js Ver fichero

@@ -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)

+ 1
- 0
test/_files/uses_props_from_view_prototype.mustache Ver fichero

@@ -0,0 +1 @@
[{{ item.x }};{{ item.y }}]||{{#items}}[{{ a.x }};{{ a.y }} {{#a}}{{y}}{{/a}}]{{/items}}

+ 1
- 0
test/_files/uses_props_from_view_prototype.txt Ver fichero

@@ -0,0 +1 @@
[0;00]||[1;2 2][3;4 4]

Cargando…
Cancelar
Guardar