Use objects for hash value tracking
The use of arrays was incorrect for the data type and causing problems when hash keys conflicted with array behaviors.
Fixes #1194
(cherry picked from commit 768ddbd661)
This commit is contained in:
committed by
Nils Knappmeier
parent
c76ded8f0f
commit
7fcf9d24f8
@@ -543,7 +543,7 @@ JavaScriptCompiler.prototype = {
|
||||
if (this.hash) {
|
||||
this.hashes.push(this.hash);
|
||||
}
|
||||
this.hash = {values: [], types: [], contexts: [], ids: []};
|
||||
this.hash = {values: {}, types: [], contexts: [], ids: []};
|
||||
},
|
||||
popHash: function() {
|
||||
let hash = this.hash;
|
||||
|
||||
@@ -323,4 +323,15 @@ describe('Regressions', function() {
|
||||
}, 'useData': true});
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow hash with protected array names', function() {
|
||||
var obj = {array: [1], name: 'John'};
|
||||
var helpers = {
|
||||
helpa: function(options) {
|
||||
return options.hash.length;
|
||||
}
|
||||
};
|
||||
|
||||
shouldCompileTo('{{helpa length="foo"}}', [obj, helpers], 'foo');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user