Skip to content

Commit 2981de4

Browse files
committed
Add explicit goDeeper option to wraped program;Fixes #1686
According to the commit message of 279e038: " [...] Helper authors now need to take care to return the same context value whenever it is conceptually the same and to avoid behaviors that may execute children under the current context in some situations and under different contexts under other situations." I belive that metric is too implicit, as the issue demonstrates. This is because in this case the context value is not conceptually the same, but it is de facto the same value. Instead this suggests to use an explicit option flag "goDeeper" to mark when a helper definitely should go deeper. This also should be backwards safe, as it doesn't change the behavior of existing helpers, builtin or custom, except the builtin "each",
1 parent 353e0f9 commit 2981de4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/handlebars/helpers/each.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export default function(instance) {
5252
blockParams: blockParams(
5353
[context[field], field],
5454
[contextPath + field, null]
55-
)
55+
),
56+
goDeeper: true
5657
});
5758
}
5859

lib/handlebars/runtime.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,10 @@ export function wrapProgram(
323323
function prog(context, options = {}) {
324324
let currentDepths = depths;
325325
if (
326-
depths &&
327-
context != depths[0] &&
328-
!(context === container.nullContext && depths[0] === null)
326+
(depths &&
327+
context != depths[0] &&
328+
!(context === container.nullContext && depths[0] === null)) ||
329+
options.goDeeper
329330
) {
330331
currentDepths = [context].concat(depths);
331332
}

0 commit comments

Comments
 (0)