From ceab53edc05788e4318595ea759f19bb52670d6b Mon Sep 17 00:00:00 2001 From: Ravenstine Date: Sun, 7 Jun 2020 08:56:42 -0700 Subject: [PATCH] Fix logic around block content bug --- CHANGELOG.md | 6 ++++- addon/lib/block-content.js | 2 +- package.json | 2 +- .../integration/ember-custom-elements-test.js | 26 +++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6fc245..5eff753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/addon/lib/block-content.js b/addon/lib/block-content.js index 30e7100..0ab609e 100644 --- a/addon/lib/block-content.js +++ b/addon/lib/block-content.js @@ -70,7 +70,7 @@ export default class BlockContent { } captureAfterRender() { - scheduleOnce('afterRender', this, this.capture); + scheduleOnce('actions', this, this.capture); } capture() { diff --git a/package.json b/package.json index 6aba3d2..adb5596 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/integration/ember-custom-elements-test.js b/tests/integration/ember-custom-elements-test.js index 0ef5a98..229d295 100644 --- a/tests/integration/ember-custom-elements-test.js +++ b/tests/integration/ember-custom-elements-test.js @@ -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`{{this.bar}}`); + 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 {}