Merge branch '4.x' into wycats-master
# Conflicts: # spec/regressions.js
This commit is contained in:
@@ -910,7 +910,7 @@ JavaScriptCompiler.prototype = {
|
||||
let params = [],
|
||||
paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper);
|
||||
let foundHelper = this.nameLookup('helpers', name, 'helper'),
|
||||
callContext = this.aliasable(`${this.contextName(0)} != null ? ${this.contextName(0)} : {}`);
|
||||
callContext = this.aliasable(`${this.contextName(0)} != null ? ${this.contextName(0)} : (container.nullContext || {})`);
|
||||
|
||||
return {
|
||||
params: params,
|
||||
|
||||
@@ -121,6 +121,8 @@ export function template(templateSpec, env) {
|
||||
|
||||
return obj;
|
||||
},
|
||||
// An empty object to use as replacement for null-contexts
|
||||
nullContext: Object.seal({}),
|
||||
|
||||
noop: env.VM.noop,
|
||||
compilerInfo: templateSpec.compiler
|
||||
@@ -174,7 +176,7 @@ export function template(templateSpec, env) {
|
||||
export function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) {
|
||||
function prog(context, options = {}) {
|
||||
let currentDepths = depths;
|
||||
if (depths && context != depths[0]) {
|
||||
if (depths && context != depths[0] && !(context === container.nullContext && depths[0] === null)) {
|
||||
currentDepths = [context].concat(depths);
|
||||
}
|
||||
|
||||
|
||||
@@ -288,4 +288,9 @@ describe('Regressions', function() {
|
||||
|
||||
shouldCompileTo('{{helpa length="foo"}}', [obj, helpers], 'foo');
|
||||
});
|
||||
|
||||
it('GH-1319: "unless" breaks when "each" value equals "null"', function() {
|
||||
var string = '{{#each list}}{{#unless ./prop}}parent={{../value}} {{/unless}}{{/each}}';
|
||||
shouldCompileTo(string, { value: 'parent', list: [ null, 'a'] }, 'parent=parent parent=parent ', '');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user