Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <h1>DONE</h1>
  11. <say-hello who="World"></say-hello>
  12. <script id="jsbin-javascript">
  13. class SayHello extends HTMLElement {
  14.  
  15. constructor() {
  16. super();
  17. this.innerHTML="EMPTY";
  18. console.log("SayHello is constructed");
  19. }
  20.  
  21. static get observedAttributes() {
  22. return ["who"];
  23. }
  24.  
  25. connectedCallback() {
  26. this.innerText = "Hello " + this.getAttribute('who') + "!";
  27. console.log("SayHello is connected to DOM")
  28. }
  29.  
  30. disconnectedCallback() {
  31. console.log("SayHello is disconnected");
  32. }
  33.  
  34. attributesChanged(name, oldValue, newValue) {
  35. if (name == "who") this.innerText = "Hello " + newValue + "!";
  36. console.log("SayHello attribute " + name + " changed from " + oldValue +" to " + newValue);
  37. }
  38. }
  39. customElements.define('say-hello', SayHello);
  40.  
  41.  
  42. </script>
  43.  
  44.  
  45.  
  46. <script id="jsbin-source-javascript" type="text/javascript"> class SayHello extends HTMLElement {
  47.  
  48. constructor() {
  49. super();
  50. this.innerHTML="EMPTY";
  51. console.log("SayHello is constructed");
  52. }
  53.  
  54. static get observedAttributes() {
  55. return ["who"];
  56. }
  57.  
  58. connectedCallback() {
  59. this.innerText = "Hello " + this.getAttribute('who') + "!";
  60. console.log("SayHello is connected to DOM")
  61. }
  62.  
  63. disconnectedCallback() {
  64. console.log("SayHello is disconnected");
  65. }
  66.  
  67. attributesChanged(name, oldValue, newValue) {
  68. if (name == "who") this.innerText = "Hello " + newValue + "!";
  69. console.log("SayHello attribute " + name + " changed from " + oldValue +" to " + newValue);
  70. }
  71. }
  72. customElements.define('say-hello', SayHello);
  73.  
  74. </script></body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement