Skip to content

Commit f2f9f10

Browse files
authored
Merge pull request #138 from relu91/fix/core-renderer-mount-injection
Update injector for re-mounted components
2 parents 1f162e5 + f8e5b62 commit f2f9f10

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/core.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ function getRenderer(): Renderer {
2323
},
2424
mount(element, key, component, injector, props) {
2525
// LIMITATION: If an element is remounted with the same identifier, the component cannot be replaced
26-
const exists = customElements.get(key)
27-
28-
if (!exists) {
29-
customElements.define(key, createCustomElement(component, { injector }))
26+
let CustomElement = customElements.get(key)
27+
28+
if (!CustomElement) {
29+
CustomElement = createCustomElement(component, { injector })
30+
customElements.define(key, CustomElement)
3031
}
3132

32-
const ngElement = document.createElement(key) as NodeProps & NgElement & typeof props
33+
const ngElement = new CustomElement(injector) as NodeProps & NgElement & typeof props
3334

3435
Object.keys(props).forEach(key => {
3536
ngElement[key] = props[key]

0 commit comments

Comments
 (0)