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

Introduces island-outlet #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions addon/components/island-outlet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Ember from 'ember';
import WormholeComponent from 'ember-wormhole/components/ember-wormhole';

const {
assert,
Component,
computed,
getOwner,
guidFor
} = Ember;

const Outlet = WormholeComponent.extend({
classNames: ['island-outlet'],
destinationElement: computed('outletName', {
get() {
let name = this.get('outletName');
assert('An outlet name is mandatory', name);
let $element = $(`[data-outlet="${name}"]`);
assert(`No outlet found with the name "${name}"`, $element.length !== 0);
assert(`Multiple outlets with the name "${name}"`, $element.length === 1);
return $element.get(0);
}
}).readOnly()
});

Outlet.reopenClass({
positionalParams: ['outletName']
});

export default Outlet;
1 change: 1 addition & 0 deletions app/components/island-outlet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-islands/components/island-outlet';
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"ujs"
],
"dependencies": {
"ember-getowner-polyfill": "1.0.0"
"ember-getowner-polyfill": "1.0.0",
"ember-wormhole": "0.5.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
1 change: 1 addition & 0 deletions tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{{content-for 'head-footer'}}
</head>
<body>
<div data-outlet="main"></div>
{{content-for 'body'}}

<p>Some static content in the index page</p>
Expand Down
3 changes: 3 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{{dummy-application}}
{{#island-outlet "main"}}
Yay
{{/island-outlet}}
25 changes: 25 additions & 0 deletions tests/integration/components/island-outlet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('island-outlet', 'Integration | Component | island outlet', {
integration: true
});

test('it renders', function(assert) {

// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });" + EOL + EOL +

this.render(hbs`{{island-outlet}}`);

assert.equal(this.$().text().trim(), '');

// Template block usage:" + EOL +
this.render(hbs`
{{#island-outlet}}
template block text
{{/island-outlet}}
`);

assert.equal(this.$().text().trim(), 'template block text');
});