Skip to content

Commit 68d78e2

Browse files
committed
ensure that mediaKeys is stringified in UI
1 parent 34662eb commit 68d78e2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/api/mediaMonitor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ function formatPropValue(prop: string, value: unknown): any {
138138
} else if ('srcObject' === prop) {
139139
rv = value ? `${value}` : value;
140140
} else if ('mediaKeys' === prop) {
141-
// `mediaKeys` serialization cautious implementation
142141
rv = cloneObjectSafely(value);
143142
} else if (value instanceof TimeRanges) {
144143
rv = [];

src/view/components/MediaMetrics.svelte

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
property: property as keyof HTMLMediaElement,
2020
});
2121
}
22+
23+
function propValueFilter(value: unknown) {
24+
if (value && typeof value === 'object') {
25+
return JSON.stringify(value);
26+
}
27+
28+
return value;
29+
}
2230
</script>
2331

2432
<table class="group">
@@ -45,13 +53,7 @@
4553
<caption class="bc-invert ta-l">Properties</caption>
4654
<tbody>
4755
{#each Object.entries(metrics.props) as [label, value] (label)}
48-
<tr
49-
class:isPassive={null === value ||
50-
false === value ||
51-
'' === value ||
52-
0 === value}
53-
class:isActive={true === value}
54-
>
56+
<tr class:isPassive={!value} class:isActive={true === value}>
5557
<td class="item-label">{label}</td>
5658
<td class="item-value">
5759
{#if isToggable(label)}
@@ -69,7 +71,7 @@
6971
{:else if ['networkState', 'readyState'].includes(label)}
7072
<Variable {value} />
7173
{:else}
72-
{value}
74+
{propValueFilter(value)}
7375
{/if}
7476
</td>
7577
</tr>

0 commit comments

Comments
 (0)