Skip to content

Commit

Permalink
Bumping @Glimmer packages to 0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chadhietala committed Mar 2, 2017
1 parent 561e7a7 commit 586d038
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"link:glimmer": "node bin/yarn-link-glimmer.js"
},
"dependencies": {
"@glimmer/compiler": "^0.21.1",
"@glimmer/di": "0.1.8",
"@glimmer/node": "^0.21.1",
"@glimmer/reference": "^0.21.0",
"@glimmer/runtime": "^0.21.1",
"@glimmer/util": "^0.21.0",
"@glimmer/compiler": "^0.22.0",
"@glimmer/di": "^0.1.8",
"@glimmer/node": "^0.22.0",
"@glimmer/reference": "^0.22.0",
"@glimmer/runtime": "^0.22.0",
"@glimmer/util": "^0.22.0",
"broccoli-funnel": "^1.0.6",
"broccoli-merge-trees": "^1.1.4",
"ember-cli-get-component-path-option": "^1.0.0",
Expand All @@ -58,7 +58,7 @@
"simple-html-tokenizer": "^0.3.0"
},
"devDependencies": {
"@glimmer/test-helpers": "^0.21.1",
"@glimmer/test-helpers": "^0.22.0",
"aws-sdk": "~2.2.43",
"babel-plugin-feature-flags": "^0.2.3",
"babel-plugin-filter-imports": "~0.2.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/ember-glimmer/lib/utils/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {
map,
referenceFromParts
} from '@glimmer/reference';
import {
Ops
} from '@glimmer/wire-format';
import { get, assert } from 'ember-metal';
import { String as StringUtils } from 'ember-runtime';
import { ROOT_REF } from '../component';
Expand Down Expand Up @@ -40,11 +43,11 @@ export function wrapComponentClassAttribute(hash) {
if (index !== -1) {
let [ type ] = values[index];

if (type === 'get') {
if (type === Ops.Get) {
let getExp = values[index];
let path = getExp[1];
let propName = path[path.length - 1];
hash[1][index] = ['helper', ['-class'], [getExp, propName]];
hash[1][index] = [Ops.Helper, ['-class'], [getExp, propName]];
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/ember-template-compiler/lib/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import TransformInputTypeSyntax from './transform-input-type-syntax';
import TransformAttrsIntoArgs from './transform-attrs-into-args';
import TransformEachInIntoEach from './transform-each-in-into-each';
import TransformHasBlockSyntax from './transform-has-block-syntax';
import TransformDotComponentInvocation from './transform-dot-component-invocation';

export default Object.freeze([
TransformDotComponentInvocation,
TransformOldBindingSyntax,
TransformItemClass,
TransformAngleBracketComponents,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

/**
Transforms dot invocation of closure components to be wrapped
with the component helper. This allows for a more static invocation
of the component.
```handlebars
{{#my-component as |comps|}}
{{comp.dropdown isOpen=false}}
{{/my-component}}
```
with
```handlebars
{{#my-component as |comps|}}
{{component comp.dropdown isOpen=false}}
{{/my-component}}
```
and
```handlebars
{{#my-component as |comps|}}
{{comp.dropdown isOpen}}
{{/my-component}}
```
with
```handlebars
{{#my-component as |comps|}}
{{component comp.dropdown isOpen}}
{{/my-component}}
```
and
```handlebars
{{#my-component as |comps|}}
{{#comp.dropdown}}Open{{/comp.dropdown}}
{{/my-component}}
```
with
```handlebars
{{#my-component as |comps|}}
{{#component comp.dropdown}}Open{{/component}}
{{/my-component}}
```
@private
@class TransFormDotComponentInvocation
*/
export default class TransFormDotComponentInvocation {

_isMulipartPath(path) {
return path.parts.length > 1;
}

_isInlineInvocation(path, params, hash) {
if (this._isMulipartPath(path)) {
if (params.length > 0 || hash.pairs.length > 0) {
return true;
}
}

return false;
}

_wrapInComponent(node, builder) {
let component = node.path;
let componentHelper = builder.path('component');
node.path = componentHelper;
node.params.unshift(component);
}

transform(ast) {
let { traverse, builders: b } = this.syntax;

traverse(ast, {
BlockStatement: (node) => {
node.program.body = node.program.body.map((_node) => {
switch(_node.type) {
case 'MustacheStatement':
if (this._isInlineInvocation(_node.path, _node.params, _node.hash)) {
this._wrapInComponent(_node, b);
}
break;
case 'BlockStatement':
if (this._isMulipartPath(_node.path)) {
this._wrapInComponent(_node, b)
}
break;
}

return _node;
});

return node;
}
});

return ast;
}
}

0 comments on commit 586d038

Please sign in to comment.