Skip to content

Commit

Permalink
[BUGFIX beta] Allow any expression for {{input type=***}}.
Browse files Browse the repository at this point in the history
(cherry picked from commit 771cbec)
  • Loading branch information
rwjblue committed Jan 24, 2017
1 parent 8d83849 commit 70ac347
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 21 additions & 0 deletions packages/ember-glimmer/tests/integration/helpers/input-test.js
Expand Up @@ -436,6 +436,27 @@ moduleFor('Helpers test: {{input}} with dynamic type', class extends InputRender
this.assertAttr('type', 'password');
}

['@test a subexpression can be used to determine type']() {
this.render(`{{input type=(if isTruthy trueType falseType)}}`, {
isTruthy: true,
trueType: 'text',
falseType: 'password'
});

this.assertAttr('type', 'text');

this.runTask(() => this.rerender());

this.assertAttr('type', 'text');

this.runTask(() => set(this.context, 'isTruthy', false));

this.assertAttr('type', 'password');

this.runTask(() => set(this.context, 'isTruthy', true));

this.assertAttr('type', 'text');
}
});

moduleFor(`Helpers test: {{input type='checkbox'}}`, class extends InputRenderingTest {
Expand Down
Expand Up @@ -62,8 +62,6 @@ function insertTypeHelperParameter(node, builders) {
}
}
if (pair && pair.value.type !== 'StringLiteral') {
let path = pair.value.path ? pair.value.path.original : pair.value.original;

node.params.unshift(builders.sexpr('-input-type', [builders.path(path, pair.loc)], null, pair.loc));
node.params.unshift(builders.sexpr('-input-type', [pair.value], null, pair.loc));
}
}

0 comments on commit 70ac347

Please sign in to comment.