Skip to content

Commit

Permalink
Merge pull request #19382 from emberjs/refactor-input-component
Browse files Browse the repository at this point in the history
[FEATURE modernized-built-in-components] Remaining implementation work
  • Loading branch information
rwjblue committed Feb 26, 2021
2 parents 9295b59 + 3d02784 commit 4cb7da4
Show file tree
Hide file tree
Showing 39 changed files with 4,459 additions and 2,090 deletions.
5 changes: 3 additions & 2 deletions packages/@ember/-internals/glimmer/index.ts
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 LinkComponent } from './lib/components/link-to';
export { default as TextArea } from './lib/components/-textarea';
export { default as LinkComponent } from './lib/components/-link-to';
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
16 changes: 11 additions & 5 deletions packages/@ember/-internals/glimmer/lib/component-managers/curly.ts
Expand Up @@ -8,6 +8,7 @@ import { assign } from '@ember/polyfills';
import { DEBUG } from '@glimmer/env';
import {
Bounds,
CapturedArguments,
CompilableProgram,
Destroyable,
ElementOperations,
Expand Down Expand Up @@ -178,14 +179,19 @@ export default class CurlyComponentManager

prepareArgs(ComponentClass: ComponentFactory, args: VMArguments): Option<PreparedArguments> {
if (args.named.has('__ARGS__')) {
assert(
'[BUG] cannot pass both __ARGS__ and positional arguments',
args.positional.length === 0
);

let { __ARGS__, ...rest } = args.named.capture();

// does this need to be untracked?
let __args__ = valueForRef(__ARGS__) as CapturedArguments;

let prepared = {
positional: EMPTY_POSITIONAL_ARGS,
named: {
...rest,
...(valueForRef(__ARGS__) as { [key: string]: Reference }),
},
positional: __args__.positional,
named: { ...rest, ...__args__.named },
};

return prepared;
Expand Down

This file was deleted.

64 changes: 63 additions & 1 deletion packages/@ember/-internals/glimmer/lib/component.ts
@@ -1,6 +1,6 @@
import { get, PROPERTY_DID_CHANGE } from '@ember/-internals/metal';
import { getOwner } from '@ember/-internals/owner';
import { TargetActionSupport } from '@ember/-internals/runtime';
import { CoreObject, TargetActionSupport } from '@ember/-internals/runtime';
import {
ActionSupport,
ChildViewsSupport,
Expand All @@ -10,6 +10,7 @@ import {
ViewMixin,
ViewStateSupport,
} from '@ember/-internals/views';
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS } from '@ember/canary-features';
import { assert, deprecate } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import { setInternalComponentManager } from '@glimmer/manager';
Expand Down Expand Up @@ -1065,4 +1066,65 @@ Component.reopenClass({

setInternalComponentManager(CURLY_COMPONENT_MANAGER, Component);

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

Object.defineProperty(Component, 'reopen', {
configurable: true,
enumerable: false,
writable: true,
value: function reopen(this: typeof Component, ...args: unknown[]): unknown {
if (this === Component) {
deprecate(
'Reopening the Ember.Component super class itself is deprecated. ' +
'Consider alternatives such as installing event listeners on ' +
'the document or add the customizations to specific subclasses.',
false,
{
id: 'ember.component.reopen',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

Component._wasReopened = true;
}

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

Object.defineProperty(Component, 'reopenClass', {
configurable: true,
enumerable: false,
writable: true,
value: function reopenClass(this: typeof Component, ...args: unknown[]): unknown {
if (this === Component) {
deprecate(
'Reopening the Ember.Component super class itself is deprecated. ' +
'Consider alternatives such as installing event listeners on ' +
'the document or add the customizations to specific subclasses.',
false,
{
id: 'ember.component.reopen',
for: 'ember-source',
since: {},
until: '4.0.0',
}
);

Component._wasReopened = true;
}

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

export default Component;

0 comments on commit 4cb7da4

Please sign in to comment.