diff --git a/list/list.js b/list/list.js index df56ad79d7d..53fe1230f3b 100644 --- a/list/list.js +++ b/list/list.js @@ -112,16 +112,18 @@ steal("can/util", "can/map", "can/map/bubble.js",function (can, Map, bubble) { Map.prototype._triggerChange.apply(this, arguments); // `batchTrigger` direct add and remove events... - if (!~attr.indexOf('.')) { + var index = +attr; + // Make sure this is not nested and not an expando + if (!~attr.indexOf('.') && !isNaN(index)) { if (how === 'add') { - can.batch.trigger(this, how, [newVal, +attr]); + can.batch.trigger(this, how, [newVal, index]); can.batch.trigger(this, 'length', [this.length]); } else if (how === 'remove') { - can.batch.trigger(this, how, [oldVal, +attr]); + can.batch.trigger(this, how, [oldVal, index]); can.batch.trigger(this, 'length', [this.length]); } else { - can.batch.trigger(this, how, [newVal, +attr]); + can.batch.trigger(this, how, [newVal, index]); } } diff --git a/view/mustache/mustache_test.js b/view/mustache/mustache_test.js index aca794af10c..aa5ab72b85d 100644 --- a/view/mustache/mustache_test.js +++ b/view/mustache/mustache_test.js @@ -3656,4 +3656,23 @@ steal("can/model", "can/view/mustache", "can/test", "can/view/mustache/spec/spec data.attr("show", true); equal(frag.childNodes[0].innerHTML, "Is showing", "Not showing the else"); }); + + test("Expandos (#744)", function(){ + var template = can.mustache("{{#each items}}