Last active
October 23, 2019 19:12
-
-
Save melvinroest/5b85957f52aba288bfe9e94ce42b811e to your computer and use it in GitHub Desktop.
EmberJS Extending HTML Element with a Web Component Fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/initializers/custom-elements.js | |
class HelloWorld extends HTMLElement { | |
constructor() { | |
super(); | |
console.log("constructor() HelloWorld"); | |
let shadowRoot = this.attachShadow({ mode: "open" }); | |
shadowRoot.innerHTML = `<p>hello world</p>`; | |
} | |
} | |
//similar to HelloWorld -- it's simply an extension | |
class TestingAParagraph extends HTMLParagraphElement { | |
constructor() { | |
super(); | |
console.log("constructor() TestingAParagraph"); | |
let shadowRoot = this.attachShadow({ mode: "open" }); | |
shadowRoot.innerHTML = `<p>hello Mars</p>`; | |
} | |
} | |
export function initialize(application) { | |
console.log('initialize()'); | |
window.customElements.define("hello-world", HelloWorld); | |
window.customElements.define("testing-a-paragraph", TestingAParagraph, { | |
extends: "p" | |
}); | |
} | |
export default { | |
initialize | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment