From 1fd0363a1e1aba64bab0a60d614b30445a5001fe Mon Sep 17 00:00:00 2001 From: StrahilKazlachev Date: Thu, 6 Sep 2018 21:04:03 +0300 Subject: [PATCH] fix(view): skip view distribution on slot fallback fix #639 let ShadowSlot and PassThroughSlot handle nodes/view distribution themselves --- src/shadow-dom.js | 2 ++ src/view.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shadow-dom.js b/src/shadow-dom.js index ca3f036c..6403fa70 100644 --- a/src/shadow-dom.js +++ b/src/shadow-dom.js @@ -40,6 +40,7 @@ export class PassThroughSlot { renderFallbackContent(view, nodes, projectionSource, index) { if (this.contentView === null) { this.contentView = this.fallbackFactory.create(this.ownerView.container); + this.contentView._isSlotFallback = true; this.contentView.bind(this.ownerView.bindingContext, this.ownerView.overrideContext); let slots = Object.create(null); @@ -277,6 +278,7 @@ export class ShadowSlot { renderFallbackContent(view, nodes, projectionSource, index) { if (this.contentView === null) { this.contentView = this.fallbackFactory.create(this.ownerView.container); + this.contentView._isSlotFallback = true; this.contentView.bind(this.ownerView.bindingContext, this.ownerView.overrideContext); this.contentView.insertNodesBefore(this.anchor); } diff --git a/src/view.js b/src/view.js index fb1af83c..b506cec6 100644 --- a/src/view.js +++ b/src/view.js @@ -88,6 +88,7 @@ export class View { this.viewModelScope = null; this.animatableElement = undefined; this._isUserControlled = false; + this._isSlotFallback = false; this.contentView = null; for (let key in slots) { @@ -166,7 +167,7 @@ export class View { children[i].bind(bindingContext, overrideContext, true); } - if (this.hasSlots) { + if (this.hasSlots && !this._isSlotFallback) { ShadowDOM.distributeView(this.contentView, this.slots); } }