Skip to content

Commit

Permalink
[LiveComponent] Prevent __component property to be serialized when …
Browse files Browse the repository at this point in the history
…called `JSON.stringify()`
  • Loading branch information
Kocal committed Jan 30, 2025
1 parent ec09cdf commit 05dc157
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,10 @@ class LiveControllerDefault extends Controller {
const id = this.element.id || null;
this.component = new Component(this.element, this.nameValue, this.propsValue, this.listenersValue, id, LiveControllerDefault.backendFactory(this), new StimulusElementDriver(this));
this.proxiedComponent = proxifyComponent(this.component);
this.element.__component = this.proxiedComponent;
Object.defineProperty(this.element, '__component', {
value: this.proxiedComponent,
writable: true,
});
if (this.hasDebounceValue) {
this.component.defaultDebounce = this.debounceValue;
}
Expand Down
6 changes: 4 additions & 2 deletions src/LiveComponent/assets/src/live_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,10 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
);
this.proxiedComponent = proxifyComponent(this.component);

// @ts-ignore Adding the dynamic property
this.element.__component = this.proxiedComponent;
Object.defineProperty(this.element, '__component', {
value: this.proxiedComponent,
writable: true,
});

if (this.hasDebounceValue) {
this.component.defaultDebounce = this.debounceValue;
Expand Down

0 comments on commit 05dc157

Please sign in to comment.