Walk up data frames for nested @partial-block
The root cause of #1218 is that `invokePartial` creates a stack of data frames for nested partial blocks, but `resolvePartial` always uses the value at top of the stack without "popping" it. The result is an infinite recursive loop, as references to `@partial-block` in the partial at the top of the stack resolve to itself. So, walk up the stack of data frames when evaluating. This is accomplished by 1) setting the `partial-block` property to `noop` after use and 2) using `_parent['partial-block']` if `partial-block` is `noop` Fix #1218
This commit is contained in:
@@ -210,7 +210,12 @@ export function wrapProgram(container, i, fn, data, declaredBlockParams, blockPa
|
||||
export function resolvePartial(partial, context, options) {
|
||||
if (!partial) {
|
||||
if (options.name === '@partial-block') {
|
||||
partial = options.data['partial-block'];
|
||||
let data = options.data;
|
||||
while (data['partial-block'] === noop) {
|
||||
data = data._parent;
|
||||
}
|
||||
partial = data['partial-block'];
|
||||
data['partial-block'] = noop;
|
||||
} else {
|
||||
partial = options.partials[options.name];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user