Skip to content

Commit

Permalink
[FEATURE modernized-built-in-components] Extract shared code
Browse files Browse the repository at this point in the history
Refactor to extra shared code into internal component to pave way
for implementing <LinkTo> with the new infrastructure.

Part of #19270
  • Loading branch information
chancancode committed Feb 13, 2021
1 parent 533c9af commit d2b8b58
Show file tree
Hide file tree
Showing 10 changed files with 1,114 additions and 997 deletions.
5 changes: 3 additions & 2 deletions packages/@ember/-internals/glimmer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,10 @@ export { templateFactory as template, templateCacheCounters } from '@glimmer/opc
export { default as RootTemplate } from './lib/templates/root';
export { default as Checkbox } from './lib/components/checkbox';
export { default as TextField } from './lib/components/text-field';
export { default as TextArea } from './lib/components/textarea';
export { default as TextArea } from './lib/components/-textarea';
export { default as LinkComponent } from './lib/components/link-to';
export { default as Input, TextareaComponent as Textarea } from './lib/components/input';
export { default as Input } from './lib/components/input';
export { default as Textarea } from './lib/components/textarea';
export { default as Component } from './lib/component';
export { default as Helper, helper } from './lib/helper';
export { SafeString, escapeExpression, htmlSafe, isHTMLSafe } from './lib/utils/string';
Expand Down

This file was deleted.

103 changes: 103 additions & 0 deletions packages/@ember/-internals/glimmer/lib/components/-textarea.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
@module @ember/component
*/
import { CoreObject } from '@ember/-internals/runtime';
import { TextSupport } from '@ember/-internals/views';
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { deprecate } from '@ember/debug';
import Component from '../component';
import layout from '../templates/empty';

/**
The internal representation used for `Textarea` invocations.
@class TextArea
@extends Component
@see {Ember.Templates.components.Textarea}
@uses Ember.TextSupport
@public
*/
const TextArea = Component.extend(TextSupport, {
classNames: ['ember-text-area'],

layout,

tagName: 'textarea',
attributeBindings: [
'rows',
'cols',
'name',
'selectionEnd',
'selectionStart',
'autocomplete',
'wrap',
'lang',
'dir',
'value',
],
rows: null,
cols: null,
});

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

if (EMBER_MODERNIZED_BUILT_IN_COMPONENTS) {
Object.defineProperty(TextArea, '_wasReopened', {
configurable: true,
enumerable: false,
writable: true,
value: false,
});

Object.defineProperty(TextArea, 'reopen', {
configurable: true,
enumerable: false,
writable: true,
value: function reopen(this: typeof TextArea, ...args: unknown[]): unknown {
if (this === TextArea) {
deprecate(
'Reopening Ember.TextArea is deprecated. Consider implementing your own ' +
'wrapper component or create a custom subclass.',
false,
{
id: 'ember.built-in-components.reopen',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

TextArea._wasReopened = true;
}

return CoreObject.reopen.call(this, ...args);
},
});

Object.defineProperty(TextArea, 'reopenClass', {
configurable: true,
enumerable: false,
writable: true,
value: function reopenClass(this: typeof TextArea, ...args: unknown[]): unknown {
if (this === TextArea) {
deprecate(
'Reopening Ember.TextArea is deprecated. Consider implementing your own ' +
'wrapper component or create a custom subclass.',
false,
{
id: 'ember.built-in-components.reopen',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

TextArea._wasReopened = true;
}

return CoreObject.reopenClass.call(this, ...args);
},
});
}

export default TextArea;

0 comments on commit d2b8b58

Please sign in to comment.