Skip to content

Commit fd69421

Browse files
committed
Merge pull request #13359 from rwjblue/link-subexpr-helpers
[BUGFIX beta] Fix subexpr `{{if}}` / `{{unless}}` to use protocol.
2 parents 97a2d96 + dd38937 commit fd69421

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

packages/ember-glimmer/tests/integration/helpers/if-unless-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ moduleFor('Helpers test: inline {{if}}', class extends TogglingHelperConditional
2121

2222
});
2323

24-
moduleFor('@glimmer Helpers test: nested {{if}} helpers (returning truthy values)', class extends TogglingHelperConditionalsTest {
24+
moduleFor('Helpers test: nested {{if}} helpers (returning truthy values)', class extends TogglingHelperConditionalsTest {
2525

2626
templateFor({ cond, truthy, falsy }) {
2727
return `{{if (if ${cond} ${cond} false) ${truthy} ${falsy}}}`;
2828
}
2929

3030
});
3131

32-
moduleFor('@glimmer Helpers test: nested {{if}} helpers (returning falsy values)', class extends TogglingHelperConditionalsTest {
32+
moduleFor('Helpers test: nested {{if}} helpers (returning falsy values)', class extends TogglingHelperConditionalsTest {
3333

3434
templateFor({ cond, truthy, falsy }) {
3535
return `{{if (if ${cond} true ${cond}) ${truthy} ${falsy}}}`;
3636
}
3737

3838
});
3939

40-
moduleFor('@glimmer Helpers test: {{if}} used with another helper', class extends TogglingHelperConditionalsTest {
40+
moduleFor('Helpers test: {{if}} used with another helper', class extends TogglingHelperConditionalsTest {
4141

4242
wrapperFor(templates) {
4343
return `{{concat ${templates.join(' ')}}}`;

packages/ember-htmlbars/lib/hooks/link-render-node.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ export default function linkRenderNode(renderNode, env, scope, path, params, has
2121
let keyword = env.hooks.keywords[path];
2222
if (keyword && keyword.link) {
2323
keyword.link(renderNode.getState(), params, hash);
24+
} else if (path === 'unbound') {
25+
return true;
2426
} else {
25-
switch (path) {
26-
case 'unbound': return true;
27-
case 'unless':
28-
case 'if': params[0] = shouldDisplay(params[0], toBool); break;
29-
case 'each': params[0] = eachParam(params[0]); break;
30-
case 'with': params[0] = shouldDisplay(params[0], identity); break;
31-
}
27+
linkParamsFor(path, params);
3228
}
3329

3430
// If there is a dot in the path, we need to subscribe to the arguments in the
@@ -65,6 +61,15 @@ export default function linkRenderNode(renderNode, env, scope, path, params, has
6561
return true;
6662
}
6763

64+
export function linkParamsFor(path, params) {
65+
switch (path) {
66+
case 'unless':
67+
case 'if': params[0] = shouldDisplay(params[0], toBool); break;
68+
case 'each': params[0] = eachParam(params[0]); break;
69+
case 'with': params[0] = shouldDisplay(params[0], identity); break;
70+
}
71+
}
72+
6873
function eachParam(list) {
6974
let listChange = getKey(list, '[]');
7075

packages/ember-htmlbars/lib/hooks/subexpr.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
labelsFor,
1010
labelFor
1111
} from 'ember-metal/streams/utils';
12+
import { linkParamsFor } from 'ember-htmlbars/hooks/link-render-node';
1213

1314
export default function subexpr(env, scope, helperName, params, hash) {
1415
// TODO: Keywords and helper invocation should be integrated into
@@ -18,6 +19,8 @@ export default function subexpr(env, scope, helperName, params, hash) {
1819
return keyword(null, env, scope, params, hash, null, null);
1920
}
2021

22+
linkParamsFor(helperName, params);
23+
2124
var label = labelForSubexpr(params, hash, helperName);
2225
var helper = lookupHelper(helperName, scope.getSelf(), env);
2326

0 commit comments

Comments
 (0)