Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <style>
  2. .editor {
  3. -webkit-user-modify:read-write-plaintext-only;
  4. background:red;
  5. }
  6. </style>
  7.  
  8. <div class="plain-text-cell editor" >Direct element</div>
  9.  
  10. class PlainTextCell extends HTMLElement {
  11. constructor() {
  12. super()
  13.  
  14. const shadowRoot = this.attachShadow({mode:'open'})
  15.  
  16. // Note: it works when using plain elements without the shadow DOM:
  17. //const shadowRoot = document.createElement('div')
  18. //this.appendChild(shadowRoot)
  19.  
  20. shadowRoot.innerHTML = `
  21. <style>
  22. .editor {
  23. -webkit-user-modify:read-write-plaintext-only;
  24. background:red;
  25. }
  26. </style>
  27.  
  28. <div class="plain-text-cell editor">Custom element</div>
  29. `
  30.  
  31. this._editor = shadowRoot.querySelector('.editor')
  32.  
  33. // Test:
  34. //this._editor.contentEditable = true // Works
  35. //this._editor.style.webkitUserModify = 'read-write-plaintext-only' // Does not work
  36. }
  37. }
  38.  
  39. customElements.define('plain-text-cell', PlainTextCell)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement