Skip to content

Commit

Permalink
Merge pull request #239 from glimmerjs/refactor/remove-custom-references
Browse files Browse the repository at this point in the history
[REFACTOR] Removes most of the remaining custom reference code.
  • Loading branch information
Chris Garrett committed Feb 14, 2020
2 parents c94a52c + eb66ed8 commit 421500e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 423 deletions.
2 changes: 0 additions & 2 deletions packages/@glimmer/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export {
export { templateOnlyComponent } from './src/managers/component/template-only';

export { createTemplate, setComponentTemplate } from './src/template';

export * from './src/references';
11 changes: 6 additions & 5 deletions packages/@glimmer/core/src/managers/component/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import {
Environment,
CompilableProgram,
} from '@glimmer/interfaces';
import { PathReference } from '@glimmer/reference';
import { PathReference, ComponentRootReference } from '@glimmer/reference';
import { Tag, isConst, createTag, consume } from '@glimmer/validator';

import { RootReference } from '../../references';
import { unwrapTemplate } from '@glimmer/opcode-compiler';

export const VM_CAPABILITIES: VMComponentCapabilities = {
Expand Down Expand Up @@ -185,7 +184,7 @@ export default class CustomComponentManager<ComponentInstance>
JitRuntimeResolver
> {
create(
_env: Environment,
env: Environment,
definition: CustomComponentDefinitionState<ComponentInstance>,
args: VMArguments
): CustomComponentState<ComponentInstance> {
Expand Down Expand Up @@ -248,7 +247,7 @@ export default class CustomComponentManager<ComponentInstance>
value
);

return new CustomComponentState(delegate, component, capturedArgs, namedArgsProxy);
return new CustomComponentState(env, delegate, component, capturedArgs, namedArgsProxy);
}

update({ delegate, component, args, namedArgsProxy }: CustomComponentState<ComponentInstance>): void {
Expand Down Expand Up @@ -279,10 +278,11 @@ export default class CustomComponentManager<ComponentInstance>
}

getSelf({
env,
delegate,
component,
}: CustomComponentState<ComponentInstance>): PathReference<unknown> {
return new RootReference(delegate.getContext(component) as object);
return new ComponentRootReference(delegate.getContext(component) as object, env);
}

getDestructor(state: CustomComponentState<ComponentInstance>): Option<Destroyable> {
Expand Down Expand Up @@ -325,6 +325,7 @@ export default class CustomComponentManager<ComponentInstance>
*/
export class CustomComponentState<ComponentInstance> {
constructor(
public env: Environment,
public delegate: ComponentManager<ComponentInstance>,
public component: ComponentInstance,
public args: CapturedArguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { CONSTANT_TAG, Tag } from '@glimmer/validator';
import { DEBUG } from '@glimmer/env';

import { unwrapTemplate } from '@glimmer/opcode-compiler';
import { RootReference } from '../../references';
import { TemplateMeta } from './custom';

export const CAPABILITIES: ComponentCapabilities = {
Expand All @@ -38,7 +37,7 @@ export class ComponentStateBucket {
constructor(public args: CapturedArguments) {}
}

const EMPTY_SELF = new RootReference({});
const EMPTY_SELF = new ConstReference(null);

let TemplateOnlyComponentDebugReference:
| undefined
Expand Down
241 changes: 0 additions & 241 deletions packages/@glimmer/core/src/references.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/@glimmer/core/test/non-interactive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ import './component-template-test';
import './manager-test';
import './render-test';
import './each-test';
import './track-property-test';
Loading

0 comments on commit 421500e

Please sign in to comment.