- From: James Browning <notifications@github.com>
- Date: Thu, 22 Feb 2018 00:58:34 -0800
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 22 February 2018 08:58:58 UTC
I think `slot.assign(element)` would be easier than `.replaceAssignment(nodes)` as you could easily just cherry pick elements you need to change slots without needing to filter `slot.assignedNodes()`. This would effectively be identical to setting `slot` on the element but would be unobservable from outside of the shadow root (for closed mode anyway, I suppose `.assignedSlot` would work as normal for open mode).
For example suppose you had some component that was a slideshow or something, you would probably want to write something like this:
```js
class SlideShow extends HTMLElement {
...
_changeToNextSlide() {
const hiddenSlides = this._shadowRoot.querySelector("#hiddenSlides")
const visibleSlide = this._shadowRoot.querySelector("#visibleSlide")
hiddenSlides.assign(this.children[this.currentSlide])
this.currentSlide += 1
visibleSlide.assign(this.children[this.currentSlide])
}
}
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/726#issuecomment-367610849
Received on Thursday, 22 February 2018 08:58:58 UTC