Skip to content

Commit

Permalink
Merge pull request #17733 from emberjs/built-in-asserts
Browse files Browse the repository at this point in the history
[BUGFIX beta] assert `<Input>` and `<Textarea>`
  • Loading branch information
rwjblue committed Mar 14, 2019
2 parents 93f49e0 + 3a545cb commit c557721
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@ember/-internals/glimmer/lib/resolver.ts
Expand Up @@ -123,9 +123,6 @@ export default class RuntimeResolver implements IRuntimeResolver<OwnedTemplateMe
* Called while executing Append Op.PushDynamicComponentManager if string
*/
lookupComponentDefinition(name: string, meta: OwnedTemplateMeta): Option<ComponentDefinition> {
assert('You cannot use `textarea` as a component name.', name !== 'textarea');
assert('You cannot use `input` as a component name.', name !== 'input');

let handle = this.lookupComponentHandle(name, meta);
if (handle === null) {
assert(
Expand Down Expand Up @@ -306,6 +303,9 @@ export default class RuntimeResolver implements IRuntimeResolver<OwnedTemplateMe
_name: string,
meta: OwnedTemplateMeta
): Option<ComponentDefinition> {
assert('You cannot use `textarea` as a component name.', _name !== 'textarea');
assert('You cannot use `input` as a component name.', _name !== 'input');

let name = _name;
let namespace = undefined;
if (EMBER_MODULE_UNIFICATION) {
Expand Down
Expand Up @@ -80,6 +80,12 @@ class InputRenderingTest extends RenderingTestCase {
moduleFor(
'Helpers test: {{input}}',
class extends InputRenderingTest {
['@test should not allow angle bracket invocation']() {
expectAssertion(() => {
this.render('<Input />');
}, 'You cannot use `input` as a component name.');
}

['@test a single text field is inserted into the DOM']() {
this.render(`{{input type="text" value=value}}`, { value: 'hello' });

Expand Down
Expand Up @@ -66,6 +66,12 @@ applyMixins(
moduleFor(
'Helpers test: {{textarea}}',
class extends TextAreaRenderingTest {
['@test Should not allow angle bracket invocation']() {
expectAssertion(() => {
this.render('<Textarea />');
}, 'You cannot use `textarea` as a component name.');
}

['@test Should insert a textarea'](assert) {
this.render('{{textarea}}');

Expand Down

0 comments on commit c557721

Please sign in to comment.