Skip to content

Commit

Permalink
Merge pull request #16307 from rwjblue/fix-display-for-text-field
Browse files Browse the repository at this point in the history
[BUGFIX beta] Ensure proper .toString() of default components.
  • Loading branch information
rwjblue authored Mar 1, 2018
2 parents 8ef8dc6 + 3462932 commit d652f47
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/ember-glimmer/lib/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
PROPERTY_DID_CHANGE,
} from 'ember-metal';
import { TargetActionSupport } from 'ember-runtime';
import { getOwner, NAME_KEY, symbol } from 'ember-utils';
import { getOwner, symbol } from 'ember-utils';
import {
ActionSupport,
ChildViewsSupport,
Expand Down Expand Up @@ -907,7 +907,7 @@ const Component = CoreView.extend(
},
);

Component[NAME_KEY] = 'Ember.Component';
Component.toString = () => '@ember/component';

Component.reopenClass({
isComponentFactory: true,
Expand Down
6 changes: 5 additions & 1 deletion packages/ember-glimmer/lib/components/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import layout from '../templates/empty';
@extends Component
@public
*/
export default EmberComponent.extend({
const Checkbox = EmberComponent.extend({
layout,
classNames: ['ember-checkbox'],

Expand Down Expand Up @@ -60,3 +60,7 @@ export default EmberComponent.extend({
set(this, 'checked', this.element.checked);
},
});

Checkbox.toString = () => '@ember/component/checkbox';

export default Checkbox;
2 changes: 1 addition & 1 deletion packages/ember-glimmer/lib/components/link-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ const LinkComponent = EmberComponent.extend({
},
});

LinkComponent.toString = () => 'LinkComponent';
LinkComponent.toString = () => '@ember/routing/link-component';

LinkComponent.reopenClass({
positionalParams: 'params',
Expand Down
6 changes: 5 additions & 1 deletion packages/ember-glimmer/lib/components/text_area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ import layout from '../templates/empty';
@uses Ember.TextSupport
@public
*/
export default Component.extend(TextSupport, {
const TextArea = Component.extend(TextSupport, {
classNames: ['ember-text-area'],

layout,
Expand All @@ -234,3 +234,7 @@ export default Component.extend(TextSupport, {
rows: null,
cols: null,
});

TextArea.toString = () => '@ember/component/text-area';

export default TextArea;
6 changes: 5 additions & 1 deletion packages/ember-glimmer/lib/components/text_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function canSetTypeOfInput(type: string) {
@uses Ember.TextSupport
@public
*/
export default Component.extend(TextSupport, {
const TextField = Component.extend(TextSupport, {
layout,
classNames: ['ember-text-field'],
tagName: 'input',
Expand Down Expand Up @@ -156,3 +156,7 @@ export default Component.extend(TextSupport, {
*/
max: null,
});

TextField.toString = () => '@ember/component/text-field';

export default TextField;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { moduleFor, RenderingTest } from '../../utils/test-case';
import { Checkbox, Component, LinkComponent, TextArea, TextField } from 'ember-glimmer';

moduleFor('built-in component toString', class AbstractAppendTest extends RenderingTest {
'@test text-field has the correct toString value'(assert) {
assert.strictEqual(TextField.toString(), '@ember/component/text-field');
}

'@test checkbox has the correct toString value'(assert) {
assert.strictEqual(Checkbox.toString(), '@ember/component/checkbox');
}

'@test text-area has the correct toString value'(assert) {
assert.strictEqual(TextArea.toString(), '@ember/component/text-area');
}

'@test component has the correct toString value'(assert) {
assert.strictEqual(Component.toString(), '@ember/component');
}

'@test LinkTo has the correct toString value'(assert) {
assert.strictEqual(LinkComponent.toString(), '@ember/routing/link-component');
}
});

0 comments on commit d652f47

Please sign in to comment.