Skip to content

Commit

Permalink
Merge pull request #14762 from jaswilli/input-type-sexpr
Browse files Browse the repository at this point in the history
[BUGFIX release] Make ember-template-compiler handle {{input}} helpers with sub-expression "type"
  • Loading branch information
rwjblue authored Jan 23, 2017
2 parents 10df1ed + 771cbec commit c998c34
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
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}}`);
});

0 comments on commit c998c34

Please sign in to comment.