Skip to content

Commit

Permalink
clone default keys, sources, and svg to prevent them from being modif…
Browse files Browse the repository at this point in the history
…ied and those modified values from leaking into other instances of this card
  • Loading branch information
Nerwyn committed Mar 13, 2024
1 parent dca3543 commit 29ec33c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/android-tv-card.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/android-tv-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ class AndroidTVCard extends LitElement {
config = this.updateDeprecatedKeys(config);

this.defaultActions = {
...defaultSources,
...defaultKeys,
...structuredClone(defaultSources),
...structuredClone(defaultKeys),
};
this.customActions = config.custom_actions || {};
if (config.slider_id && !this.customActions.slider?.tap_action) {
this.customActions.slider = {
...(this.customActions.slider ?? {}),
...structuredClone(defaultKeys.slider),
...this.defaultActions.slider,
};
this.customActions.slider.tap_action!.data!.entity_id =
config.slider_id as string;
}
this.icons = {
...svg,
...structuredClone(svg),
...config.custom_icons,
};

Expand Down

0 comments on commit 29ec33c

Please sign in to comment.