Skip to content

Commit

Permalink
fix: update in angular 19
Browse files Browse the repository at this point in the history
may affect any previous version
  • Loading branch information
Ni55aN committed Dec 29, 2024
1 parent 3b517a7 commit e77caef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createCustomElement } from '@angular/elements';

import { NgElement, NodeProps, Position, RenderSignal } from './types'
import { RenderPreset } from './presets/types';
import { reflect } from './reflect';

type Item = { key: string, ngElement: NgElement }

Expand Down Expand Up @@ -39,9 +40,8 @@ function getRenderer(): Renderer {
},
update({ ngElement }, props) {
Object.keys(props).forEach(key => {
ngElement.ngElementStrategy.setInputValue(key, props[key])
ngElement.ngElementStrategy.setInputValue(key, reflect(props[key]))
})
ngElement.ngElementStrategy.setInputValue('seed', Math.random())
},
unmount(element) {
const existing = elements.get(element)
Expand Down
18 changes: 18 additions & 0 deletions src/reflect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function reflect(obj: unknown) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}

return new Proxy(obj, {
get(target, prop) {
return target[prop];
},
set(target, prop, value) {
target[prop] = value;
return true;
},
has: (target, prop) => prop in target,
deleteProperty: (target, prop) => delete target[prop],
ownKeys: target => Reflect.ownKeys(target)
});
}

0 comments on commit e77caef

Please sign in to comment.