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

[GLIMMER] Fix {{has-block}} {{has-block-params}} and {{yield}} in partials #14633

Merged
merged 2 commits into from
Nov 26, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"git-repo-info": "^1.1.4",
"git-repo-version": "^0.3.1",
"github": "^0.2.3",
"glimmer-engine": "^0.18.2",
"glimmer-engine": "^0.19.1",
"glob": "^5.0.13",
"html-differ": "^1.3.4",
"jquery": "^3.1.1",
Expand Down
9 changes: 4 additions & 5 deletions packages/ember-glimmer/lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ export default class Environment extends GlimmerEnvironment {
isModifier,
key,
path,
args,
templates
args
} = statement;

assert(`You attempted to overwrite the built-in helper "${key}" which is not allowed. Please rename the helper.`, !(this.builtInHelpers[key] && this.owner.hasRegistration(`helper:${key}`)));
Expand All @@ -189,7 +188,7 @@ export default class Environment extends GlimmerEnvironment {

let RefinedSyntax = findSyntaxBuilder(key);
if (RefinedSyntax) {
return RefinedSyntax.create(this, args, templates, symbolTable);
return RefinedSyntax.create(this, args, symbolTable);
}

let internalKey = builtInComponents[key];
Expand All @@ -204,7 +203,7 @@ export default class Environment extends GlimmerEnvironment {
if (definition) {
wrapComponentClassAttribute(args);

return new CurlyComponentSyntax(args, definition, templates, symbolTable);
return new CurlyComponentSyntax(args, definition, symbolTable);
}

assert(`A component or helper named "${key}" could not be found`, !isBlock || this.hasHelper(path, symbolTable));
Expand All @@ -215,7 +214,7 @@ export default class Environment extends GlimmerEnvironment {
}

if (!isSimple && path) {
return DynamicComponentSyntax.fromPath(this, path, args, templates, symbolTable);
return DynamicComponentSyntax.fromPath(this, path, args, symbolTable);
}

assert(`Helpers may not be used in the block form, for example {{#${key}}}{{/${key}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${key})}}{{/if}}.`, !isBlock || !this.hasHelper(path, symbolTable));
Expand Down
4 changes: 3 additions & 1 deletion packages/ember-glimmer/lib/helpers/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
validatePositionalParameters
} from '../syntax/curly-component';
import {
Blocks,
EvaluatedArgs,
EvaluatedNamedArgs,
EvaluatedPositionalArgs,
Expand Down Expand Up @@ -254,7 +255,8 @@ function curryArgs(definition, newArgs) {

let mergedArgs = EvaluatedArgs.create(
EvaluatedPositionalArgs.create(mergedPositional),
EvaluatedNamedArgs.create(mergedNamed)
EvaluatedNamedArgs.create(mergedNamed),
Blocks.empty()
);

return mergedArgs;
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-glimmer/lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ registerSyntax('component', DynamicComponentSyntax);
registerSyntax('input', InputSyntax);

registerSyntax('-with-dynamic-vars', class {
static create(environment, args, templates, symbolTable) {
return new WithDynamicVarsSyntax({ args, templates });
static create(environment, args, symbolTable) {
return new WithDynamicVarsSyntax(args);
}
});

registerSyntax('-in-element', class {
static create(environment, args, templates, symbolTable) {
return new InElementSyntax({ args, templates });
static create(environment, args, symbolTable) {
return new InElementSyntax(args);
}
});
5 changes: 2 additions & 3 deletions packages/ember-glimmer/lib/syntax/curly-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,16 @@ function applyAttributeBindings(element, attributeBindings, component, operation
}

export class CurlyComponentSyntax extends StatementSyntax {
constructor(args, definition, templates, symbolTable) {
constructor(args, definition, symbolTable) {
super();
this.args = args;
this.definition = definition;
this.templates = templates;
this.symbolTable = symbolTable;
this.shadow = null;
}

compile(builder) {
builder.component.static(this.definition, this.args, this.templates, this.symbolTable, this.shadow);
builder.component.static(this.definition, this.args, this.symbolTable, this.shadow);
}
}

Expand Down
15 changes: 7 additions & 8 deletions packages/ember-glimmer/lib/syntax/dynamic-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,34 @@ function dynamicComponentFor(vm, symbolTable) {

export class DynamicComponentSyntax extends StatementSyntax {
// for {{component componentName}}
static create(environment, args, templates, symbolTable) {
static create(environment, args, symbolTable) {
let definitionArgs = ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1));
let invocationArgs = ArgsSyntax.build(args.positional.slice(1), args.named);
let invocationArgs = ArgsSyntax.build(args.positional.slice(1), args.named, args.blocks);

return new this(definitionArgs, invocationArgs, templates, symbolTable);
return new this(definitionArgs, invocationArgs, symbolTable);
}

// Transforms {{foo.bar with=args}} or {{#foo.bar with=args}}{{/foo.bar}}
// into {{component foo.bar with=args}} or
// {{#component foo.bar with=args}}{{/component}}
// with all of it's arguments
static fromPath(environment, path, args, templates, symbolTable) {
static fromPath(environment, path, args, symbolTable) {
let positional = ArgsSyntax.fromPositionalArgs(PositionalArgsSyntax.build([GetSyntax.build(path.join('.'))]));

return new this(positional, args, templates, symbolTable);
return new this(positional, args, symbolTable);
}

constructor(definitionArgs, args, templates, symbolTable) {
constructor(definitionArgs, args, symbolTable) {
super();
this.definition = dynamicComponentFor;
this.definitionArgs = definitionArgs;
this.args = args;
this.templates = templates;
this.symbolTable = symbolTable;
this.shadow = null;
}

compile(builder) {
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow);
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow);
}
}

Expand Down
14 changes: 7 additions & 7 deletions packages/ember-glimmer/lib/syntax/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { CurlyComponentSyntax } from './curly-component';
import { DynamicComponentSyntax } from './dynamic-component';
import { wrapComponentClassAttribute } from '../utils/bindings';

function buildTextFieldSyntax(args, templates, getDefinition, symbolTable) {
function buildTextFieldSyntax(args, getDefinition, symbolTable) {
let definition = getDefinition('-text-field');
wrapComponentClassAttribute(args);
return new CurlyComponentSyntax(args, definition, templates, symbolTable);
return new CurlyComponentSyntax(args, definition, symbolTable);
}

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ function buildTextFieldSyntax(args, templates, getDefinition, symbolTable) {
@public
*/
export const InputSyntax = {
create(environment, args, templates, symbolTable) {
create(environment, args, symbolTable) {
let getDefinition = (path) => environment.getComponentDefinition([path], symbolTable);

if (args.named.has('type')) {
Expand All @@ -161,15 +161,15 @@ export const InputSyntax = {

wrapComponentClassAttribute(args);
let definition = getDefinition('-checkbox');
return new CurlyComponentSyntax(args, definition, templates, symbolTable);
return new CurlyComponentSyntax(args, definition, symbolTable);
} else {
return buildTextFieldSyntax(args, templates, getDefinition, symbolTable);
return buildTextFieldSyntax(args, getDefinition, symbolTable);
}
}
} else {
return buildTextFieldSyntax(args, templates, getDefinition, symbolTable);
return buildTextFieldSyntax(args, getDefinition, symbolTable);
}

return DynamicComponentSyntax.create(environment, args, templates, symbolTable);
return DynamicComponentSyntax.create(environment, args, symbolTable);
}
};
2 changes: 1 addition & 1 deletion packages/ember-glimmer/lib/syntax/mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { OutletLayoutCompiler } from './outlet';
@public
*/
export class MountSyntax extends StatementSyntax {
static create(env, args, templates, symbolTable) {
static create(env, args, symbolTable) {
assert(
'You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.',
args.positional.length === 1 && args.named.length === 0
Expand Down
10 changes: 4 additions & 6 deletions packages/ember-glimmer/lib/syntax/outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,22 @@ function outletComponentFor(vm) {
@public
*/
export class OutletSyntax extends StatementSyntax {
static create(environment, args, templates, symbolTable) {
static create(environment, args, symbolTable) {
let definitionArgs = ArgsSyntax.fromPositionalArgs(args.positional.slice(0, 1));

return new this(environment, definitionArgs, templates, symbolTable);
return new this(environment, definitionArgs, symbolTable);
}

constructor(environment, args, templates, symbolTable) {
constructor(environment, args, symbolTable) {
super();
this.definitionArgs = args;
this.definition = outletComponentFor;
this.args = ArgsSyntax.empty();
this.symbolTable = symbolTable;
this.templates = null;
this.shadow = null;
}

compile(builder) {
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow);
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow);
}
}

Expand Down
9 changes: 4 additions & 5 deletions packages/ember-glimmer/lib/syntax/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,21 @@ function makeComponentDefinition(vm) {
@public
*/
export class RenderSyntax extends StatementSyntax {
static create(environment, args, templates, symbolTable) {
return new this(environment, args, templates, symbolTable);
static create(environment, args, symbolTable) {
return new this(environment, args, symbolTable);
}

constructor(environment, args, templates, symbolTable) {
constructor(environment, args, symbolTable) {
super();
this.definitionArgs = args;
this.definition = makeComponentDefinition;
this.args = ArgsSyntax.fromPositionalArgs(args.positional.slice(1, 2));
this.templates = null;
this.symbolTable = symbolTable;
this.shadow = null;
}

compile(builder) {
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.templates, this.symbolTable, this.shadow);
builder.component.dynamic(this.definitionArgs, this.definition, this.args, this.symbolTable, this.shadow);
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ember-glimmer/lib/utils/process-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
export function gatherArgs(args, definition) {
let namedMap = gatherNamedMap(args, definition);
let positionalValues = gatherPositionalValues(args, definition);
return mergeArgs(namedMap, positionalValues, definition.ComponentClass);
return mergeArgs(namedMap, positionalValues, args.blocks, definition.ComponentClass);
}

function gatherNamedMap(args, definition) {
Expand All @@ -46,7 +46,7 @@ function gatherPositionalValues(args, definition) {
}
}

function mergeArgs(namedMap, positionalValues, componentClass) {
function mergeArgs(namedMap, positionalValues, blocks, componentClass) {
let positionalParamsDefinition = componentClass.positionalParams;

if (positionalParamsDefinition && positionalParamsDefinition.length > 0 && positionalValues.length > 0) {
Expand All @@ -56,7 +56,7 @@ function mergeArgs(namedMap, positionalValues, componentClass) {
namedMap = mergePositionalParams(namedMap, positionalValues, positionalParamsDefinition);
}
}
return EvaluatedArgs.named(namedMap);
return EvaluatedArgs.named(namedMap, blocks);
}

const EMPTY_ARGS = {
Expand Down
Loading