Skip to content

Commit d493216

Browse files
committed
Fix wp-each issue with non-arrays
1 parent 469ea3e commit d493216

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

html-api-debugger/interactivity.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function generate_page( string $html, array $options ): string {
4747
'htmlApiDoctypeName' => $htmlapi_response['result']['doctypeName'] ?? null,
4848
'htmlApiDoctypePublicId' => $htmlapi_response['result']['doctypePublicId'] ?? null,
4949
'htmlApiDoctypeSytemId' => $htmlapi_response['result']['doctypeSystemId'] ?? null,
50+
'treeWarnings' => $htmlapi_response['result']['warnings'] ?? array(),
5051
'normalizedHtml' => $htmlapi_response['normalizedHtml'] ?? '',
5152

5253
'playbackLength' => isset( $htmlapi_response['result']['playback'] )
@@ -165,8 +166,8 @@ class="context-html"
165166
</div>
166167
</div>
167168

168-
<div data-wp-bind--hidden="!state.htmlapiResponse.result.warnings.0">
169-
<template data-wp-each="state.htmlapiResponse.result.warnings">
169+
<div data-wp-bind--hidden="!state.treeWarnings.length">
170+
<template data-wp-each="state.treeWarnings">
170171
<p data-wp-text="context.item" class="error-holder"></p>
171172
</template>
172173
</div>

html-api-debugger/view.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let mutationObserver = null;
6767
*
6868
*
6969
* @typedef State
70+
* @property {ReadonlyArray<string>} treeWarnings
7071
* @property {string|null} selector
7172
* @property {string|null} selectorErrorMessage
7273
* @property {boolean} showClosers
@@ -145,6 +146,10 @@ const store = createStore(NS, {
145146
};
146147
},
147148

149+
get treeWarnings() {
150+
return store.state.htmlapiResponse.result?.warnings ?? [];
151+
},
152+
148153
get playbackTree() {
149154
if (store.state.playbackPoint === null) {
150155
return undefined;

0 commit comments

Comments
 (0)