- From: Oliver Williams <notifications@github.com>
- Date: Wed, 27 Jun 2018 08:30:31 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 27 June 2018 15:30:53 UTC
[MDN](https://developer.mozilla.org/en-US/docs/Web/Events/slotchange) says > Note that it doesn't fire if you change the node contents — only if you change (e.g. add or delete) the actual nodes themselves. I have found that to be accurate. For the record, my copy to clipboard function looked like ``` connectedCallback() { let copyButton = this.shadowRoot.querySelector('button'); let svg = this.shadowRoot.querySelector('svg'); var cp = document.querySelector('copy-paste') var slot = cp.shadowRoot.querySelector('slot'); **var textToCopy = slot.assignedNodes()[0]** let span = this.shadowRoot.querySelector('span'); function selectElementContents(el) { var range = document.createRange(); range.selectNodeContents(el); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range); } function copyText() { selectElementContents(textToCopy); document.execCommand('copy'); svg.classList.remove('opacity0'); setTimeout(function() { svg.classList.add('opacity0'); }, 700); } copyButton.addEventListener('click', copyText); span.addEventListener('click', copyText); } ``` -- 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/753#issuecomment-400717658
Received on Wednesday, 27 June 2018 15:30:53 UTC