Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE modernized-built-in-components] Remaining implementation work #19382

Merged
merged 11 commits into from Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;