Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Nov 17, 2020
1 parent 45b30a5 commit 138efdd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 155 deletions.
4 changes: 0 additions & 4 deletions packages/@ember/-internals/glimmer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ export {
} from './lib/template_registry';
export { setupEngineRegistry, setupApplicationRegistry } from './lib/setup-registry';
export { DOMChanges, NodeDOMTreeConstruction, DOMTreeConstruction } from './lib/dom';
export {
registerMacros as _registerMacros,
experimentalMacros as _experimentalMacros,
} from './lib/syntax';

// needed for test
// TODO just test these through public API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export default class CurlyComponentManager
return null;
}

return { positional: EMPTY_ARRAY as readonly Reference[], named };
return { positional: EMPTY_ARRAY as Reference[], named };
}

/*
Expand Down
18 changes: 7 additions & 11 deletions packages/@ember/-internals/glimmer/lib/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { backburner, getCurrentRunLoop } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import {
Bounds,
CompileTimeCompilationContext,
Cursor,
DebugRenderTree,
DynamicScope as GlimmerDynamicScope,
Expand All @@ -14,11 +15,10 @@ import {
Option,
RenderResult,
RuntimeContext,
SyntaxCompilationContext,
Template,
TemplateFactory,
} from '@glimmer/interfaces';
import { syntaxCompilationContext } from '@glimmer/opcode-compiler';
import { programCompilationContext } from '@glimmer/opcode-compiler';
import { artifacts } from '@glimmer/program';
import { createConstRef, Reference, UNDEFINED_REFERENCE, valueForRef } from '@glimmer/reference';
import {
Expand All @@ -32,7 +32,7 @@ import {
renderMain,
runtimeContext,
} from '@glimmer/runtime';
import { unwrapHandle, unwrapTemplate } from '@glimmer/util';
import { unwrapTemplate } from '@glimmer/util';
import { CURRENT_TAG, validateTag, valueForTag } from '@glimmer/validator';
import { SimpleDocument, SimpleElement, SimpleNode } from '@simple-dom/interface';
import RSVP from 'rsvp';
Expand All @@ -43,7 +43,6 @@ import { RootComponentDefinition } from './component-managers/root';
import { NodeDOMTreeConstruction } from './dom';
import { EmberEnvironmentDelegate } from './environment';
import RuntimeResolver from './resolver';
import { populateMacros } from './syntax';
import { Component } from './utils/curly-component-state-bucket';
import { OutletState } from './utils/outlet';
import OutletView from './views/outlet';
Expand Down Expand Up @@ -117,7 +116,7 @@ class RootState {
constructor(
public root: Component | OutletView,
public runtime: RuntimeContext,
context: SyntaxCompilationContext,
context: CompileTimeCompilationContext,
template: Template,
self: Reference<unknown>,
parentElement: SimpleElement,
Expand All @@ -135,14 +134,13 @@ class RootState {

this.render = errorLoopTransaction(() => {
let layout = unwrapTemplate(template).asLayout();
let handle = layout.compile(context);

let iterator = renderMain(
runtime,
context,
self,
builder(runtime.env, { element: parentElement, nextSibling: null }),
unwrapHandle(handle),
layout,
dynamicScope
);

Expand Down Expand Up @@ -281,7 +279,7 @@ export abstract class Renderer {
private _builder: IBuilder;
private _inRenderTransaction = false;

private _context: SyntaxCompilationContext;
private _context: CompileTimeCompilationContext;
private _runtime: RuntimeContext;

private _lastRevision = -1;
Expand Down Expand Up @@ -311,9 +309,7 @@ export abstract class Renderer {

let sharedArtifacts = artifacts();

let context = (this._context = syntaxCompilationContext(sharedArtifacts, compileTimeResolver));

populateMacros(context.macros);
this._context = programCompilationContext(sharedArtifacts, compileTimeResolver);

let runtimeEnvironmentDelegate = new EmberEnvironmentDelegate(owner, env.isInteractive);
this._runtime = runtimeContext(
Expand Down
85 changes: 0 additions & 85 deletions packages/@ember/-internals/glimmer/lib/syntax.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -460,40 +460,59 @@ moduleFor(
this.assertHTML('<div data-foo-bar="baz"></div>');
}

['@test simple helper not usable with a block']() {
['@test simple helper not usable with a block'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}
this.registerHelper('some-helper', () => {});

expectAssertion(() => {
assert.throws(() => {
this.render(`{{#some-helper}}{{/some-helper}}`);
}, /Helpers may not be used in the block form/);
}, /Attempted to resolve some-helper, which was expected to be a component, but nothing was found./);
}

['@test class-based helper not usable with a block']() {
['@test class-based helper not usable with a block'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', {
compute() {},
});

expectAssertion(() => {
assert.throws(() => {
this.render(`{{#some-helper}}{{/some-helper}}`);
}, /Helpers may not be used in the block form/);
}, /Attempted to resolve some-helper, which was expected to be a component, but nothing was found./);
}

['@test simple helper not usable within element']() {
['@test simple helper not usable within element'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', () => {});

this.assert.throws(() => {
assert.throws(() => {
this.render(`<div {{some-helper}}></div>`);
}, /Error: Compile Error: Unexpected Modifier some-helper @ 0..0/);
}, /Attempted to resolve some-helper, which was expected to be a modifier, but nothing was found./);
}

['@test class-based helper not usable within element']() {
['@test class-based helper not usable within element'](assert) {
if (!DEBUG) {
assert.expect(0);
return;
}

this.registerHelper('some-helper', {
compute() {},
});

this.assert.throws(() => {
assert.throws(() => {
this.render(`<div {{some-helper}}></div>`);
}, /Error: Compile Error: Unexpected Modifier some-helper @ 0..0/);
}, /Attempted to resolve some-helper, which was expected to be a modifier, but nothing was found./);
}

['@test class-based helper is torn down'](assert) {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ember/tests/component_registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ moduleFor(
async ['@test Using name of component that does not exist'](assert) {
this.addTemplate('application', `<div id='wrapper'>{{#no-good}} {{/no-good}}</div>`);

await assert.rejectsAssertion(this.visit('/'), /.* named "no-good" .*/);
await assert.rejectsAssertion(this.visit('/'), /Attempted to resolve no-good/);
}
}
);

0 comments on commit 138efdd

Please sign in to comment.