Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Make ember-template-compiler handle {{input}} helpers with sub-expression "type" #14762

Merged
merged 2 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/ember-glimmer/tests/integration/helpers/input-test.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ function insertTypeHelperParameter(node, builders) {
}
}
if (pair && pair.value.type !== 'StringLiteral') {
node.params.unshift(builders.sexpr('-input-type', [builders.path(pair.value.original, pair.loc)], null, pair.loc));
node.params.unshift(builders.sexpr('-input-type', [pair.value], null, pair.loc));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { compile } from '../../index';

QUnit.module('ember-template-compiler: input type syntax');

QUnit.test('Can compile an {{input}} helper that has a sub-expression value as its type', function() {
expect(0);

compile(`{{input type=(if true 'password' 'text')}}`);
});

QUnit.test('Can compile an {{input}} helper with a string literal type', function() {
expect(0);

compile(`{{input type='text'}}`);
});

QUnit.test('Can compile an {{input}} helper with a type stored in a var', function() {
expect(0);

compile(`{{input type=_type}}`);
});