Skip to content

Commit

Permalink
Fix logic around block content bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravenstine committed Jun 7, 2020
1 parent 58cd741 commit ceab53e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Ember Web Components Changelog
==============================

### v0.2.0
## v0.2.1

- Fixed bug with conditional logic surrounding block content, which was causing an infinite render loop.

## v0.2.0

- Added `preserveOutletContent` option, which can be used to keep outlet DOM contents from being cleared when navigating away from a route.
- Fixed a bug in the Outlet element where router event listeners were not being removed, causing the outlet to try and update even after the outlet view has been destroyed.
2 changes: 1 addition & 1 deletion addon/lib/block-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class BlockContent {
}

captureAfterRender() {
scheduleOnce('afterRender', this, this.capture);
scheduleOnce('actions', this, this.capture);
}

capture() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-custom-elements",
"version": "0.2.0",
"version": "0.2.1",
"description": "Easily use custom elements to invoke your Ember components, routes, and applications.",
"keywords": [
"ember-addon",
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/ember-custom-elements-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ module('Integration | Component | ember-custom-elements', function(hooks) {
assert.equal(element.shadowRoot.textContent.trim(), 'foo baz baz')
});

test('it supports logic with block content', async function(assert) {
assert.expect(3);

@customElement('web-component')
class EmberCustomElement extends klass {}

const template = hbs`foo{{#if @show-content}} {{yield}}{{/if}} baz`;

setupComponentForTest(this.owner, EmberCustomElement, template, 'web-component');

set(this, 'bar', 'bar');
set(this, 'showContent', 'true');
await render(hbs`<web-component show-content={{this.showContent}}>{{this.bar}}</web-component>`);
const element = find('web-component');
assert.equal(element.shadowRoot.textContent.trim(), 'foo bar baz');

set(this, 'showContent', false);
await settled();
assert.equal(element.shadowRoot.textContent.trim(), 'foo baz');

set(this, 'bar', 'baz');
set(this, 'showContent', 'true');
await settled();
assert.equal(element.shadowRoot.textContent.trim(), 'foo baz baz');
});

test('it can render without a shadow root', async function(assert) {
@customElement('web-component', { useShadowRoot: false })
class EmberCustomElement extends klass {}
Expand Down

0 comments on commit ceab53e

Please sign in to comment.