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

Add tests for <@nav.item /> issue. #14

Merged
merged 4 commits into from
Jun 6, 2018
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
10 changes: 9 additions & 1 deletion lib/ast-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,17 @@ class AngleBracketPolyfill {
let hasAttrSplat = element.attributes.find(n => n.name === '...attributes');

if (isLocal || isNamedArgument || isThisPath) {
let path = b.path(tag);

if (isNamedArgument) {
path = b.path(tag.slice(1));
path.original = tag;
path.data = true;
}

return {
kind: 'DynamicComponent',
path: b.path(tag),
path,
selfClosing,
hasAttrSplat,
};
Expand Down
3 changes: 2 additions & 1 deletion lib/sample-compile-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/

const compiler = require('ember-source/dist/ember-template-compiler');
//compiler.registerPlugin('ast', require('ember-named-arguments-polyfill/lib/ast-transform'));
compiler.registerPlugin('ast', require('./ast-transform'));

let template = '<@nav.item />';
let template = '<@curriedThing />';
let output = compiler.precompile(template, { contents: template });
console.log(output); // eslint-disable-line no-console
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.1.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-named-arguments-polyfill": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~3.2.0-beta.2",
"ember-source-channel-url": "^1.0.1",
Expand All @@ -57,6 +58,7 @@
"node": "6.* || 8.* || 9.* || >= 10.*"
},
"ember-addon": {
"configPath": "tests/dummy/config"
"configPath": "tests/dummy/config",
"after": "ember-named-arguments-polyfill"
}
}
18 changes: 18 additions & 0 deletions tests/integration/components/angle-bracket-invocation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ module('Integration | Component | angle-bracket-invocation', function(hooks) {
assert.dom().hasText('hi rwjblue!');
});

test('invoke dynamic - named arguments', async function(assert) {
this.owner.register('template:components/x-invoker', hbs`<@curriedThing />`);
this.owner.register('template:components/foo-bar', hbs`hi rwjblue!`);

await render(hbs`{{x-invoker curriedThing=(component 'foo-bar')}}`);

assert.dom().hasText('hi rwjblue!');
});

test('invoke dynamic - named argument paths', async function(assert) {
this.owner.register('template:components/x-invoker', hbs`<@stuff.curriedThing />`);
this.owner.register('template:components/foo-bar', hbs`hi rwjblue!`);

await render(hbs`{{x-invoker stuff=(hash curriedThing=(component 'foo-bar'))}}`);

assert.dom().hasText('hi rwjblue!');
});

test('invoke dynamic - path no implicit this', async function(assert) {
this.owner.register('service:elsewhere', Service.extend());
this.owner.register(
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,13 @@ ember-maybe-import-regenerator@^0.1.6:
ember-cli-babel "^6.0.0-beta.4"
regenerator-runtime "^0.9.5"

ember-named-arguments-polyfill@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ember-named-arguments-polyfill/-/ember-named-arguments-polyfill-1.0.0.tgz#0b81fb81a7cef2c89e9e1d0278b579e708bf4ded"
dependencies:
ember-cli-babel "^6.6.0"
ember-cli-version-checker "^2.1.2"

ember-qunit@^3.3.2:
version "3.4.1"
resolved "https://registry.yarnpkg.com/ember-qunit/-/ember-qunit-3.4.1.tgz#204a2d39a5d44d494c56bf17cf3fd12f06210359"
Expand Down