Skip to content

Commit

Permalink
fix: update injector for re-mounted components
Browse files Browse the repository at this point in the history
  • Loading branch information
relu91 committed Jan 10, 2025
1 parent 43c63ac commit f8e5b62
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ function getRenderer(): Renderer {
},
mount(element, key, component, injector, props) {
// LIMITATION: If an element is remounted with the same identifier, the component cannot be replaced
const exists = customElements.get(key)

if (!exists) {
customElements.define(key, createCustomElement(component, { injector }))
let CustomElement = customElements.get(key)

if (!CustomElement) {
CustomElement = createCustomElement(component, { injector })
customElements.define(key, CustomElement)
}

const ngElement = document.createElement(key) as NodeProps & NgElement & typeof props
const ngElement = new CustomElement(injector) as NodeProps & NgElement & typeof props

Object.keys(props).forEach(key => {
ngElement[key] = props[key]
Expand Down

0 comments on commit f8e5b62

Please sign in to comment.