Skip to content

Commit 73684d4

Browse files
committed
Merge branch 'dev'
2 parents fc62b3f + 2c12bb8 commit 73684d4

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

html-api-debugger/html-api-debugger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: HTML API Debugger
44
* Plugin URI: https://github.com/sirreal/html-api-debugger
55
* Description: Add a page to wp-admin for debugging the HTML API.
6-
* Version: 2.4
6+
* Version: 2.6
77
* Requires at least: 6.7
88
* Tested up to: 6.8
99
* Author: Jon Surrell
@@ -22,7 +22,7 @@
2222
require_once __DIR__ . '/html-api-integration.php';
2323

2424
const SLUG = 'html-api-debugger';
25-
const VERSION = '2.4';
25+
const VERSION = '2.6';
2626

2727
/** Set up the plugin. */
2828
function init() {

html-api-debugger/html-api-integration.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ class_exists( '\WP_CSS_Complex_Selector_List' )
2626
* @return string|null The normalized HTML or null if not supported.
2727
*/
2828
function get_normalized_html( string $html, array $options ): ?string {
29-
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
30-
$cfacn->setAccessible( true );
29+
if ( method_exists( WP_HTML_Processor::class, 'create_fragment_at_current_node' ) ) {
30+
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
31+
$cfacn->setAccessible( true );
32+
}
3133

3234
if (
3335
method_exists( WP_HTML_Processor::class, 'create_fragment_at_current_node' ) &&
@@ -98,8 +100,10 @@ function get_tree( string $html, array $options ): array {
98100
$processor_bookmarks = new ReflectionProperty( WP_HTML_Processor::class, 'bookmarks' );
99101
$processor_bookmarks->setAccessible( true );
100102

101-
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
102-
$cfacn->setAccessible( true );
103+
if ( method_exists( WP_HTML_Processor::class, 'create_fragment_at_current_node' ) ) {
104+
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
105+
$cfacn->setAccessible( true );
106+
}
103107

104108
$is_fragment_processor = false;
105109

html-api-debugger/interactivity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class="context-html"
7979
<div>
8080
<h2>Input HTML</h2>
8181
<textarea
82-
id='input_html'
82+
id="input-html"
8383
autocapitalize="off"
8484
autocomplete="off"
8585
spellcheck="false"
@@ -153,7 +153,7 @@ class="context-html"
153153
<label>Show invisible <input type="checkbox" data-wp-bind--checked="state.showInvisible" data-wp-on-async--input="handleShowInvisibleClick"></label>
154154
<span><label>Show virtual <input type="checkbox" data-wp-bind--checked="state.showVirtual" data-wp-on-async--input="handleShowVirtualClick"></label></span>
155155
<div data-wp-bind--hidden="!state.htmlapiResponse.supports.selectors">
156-
<label>CSS Selectors <textarea placeholder="CSS selector: .my-class" data-wp-on-async--input="handleSelectorChange"><?php echo "\n" . esc_textarea( str_replace( "\0", '', $options['selector'] ?? '' ) ); ?></textarea></label>
156+
<label>CSS Selectors <textarea id="selector-input" placeholder="CSS selector: .my-class" data-wp-on-async--input="handleSelectorChange"><?php echo "\n" . esc_textarea( str_replace( "\0", '', $options['selector'] ?? '' ) ); ?></textarea></label>
157157
</div>
158158
</div>
159159
<div>

html-api-debugger/readme.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: jonsurrell, bernhard-reiter
33
Tags: HTML API, development, debug
44
Requires at least: 6.7
55
Tested up to: 6.8
6-
Stable tag: 2.4
6+
Stable tag: 2.6
77
License: GPLv2 or later
88
License URI: https://www.gnu.org/licenses/gpl-2.0.html
99

@@ -15,7 +15,15 @@ Please file issues and pull requests on the [GitHub repository](https://github.c
1515

1616
== Changelog ==
1717

18+
= 2.6 =
19+
* Handle null bytes in selectors and context HTML.
20+
* Fix another error when using WordPress 6.7.
21+
22+
= 2.5 =
23+
* Fix a crash when using WordPress 6.7.
24+
1825
= 2.4 =
26+
* Add experimental support for HTML API selectors.
1927
* Display document title.
2028

2129
= 2.3 =

html-api-debugger/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
font-size: inherit;
5959
}
6060

61-
#input_html {
61+
#input-html {
6262
width: 100%;
6363
min-height: 200px;
6464
font-family: var(--monospace-font-family);

html-api-debugger/view.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ let mutationObserver = null;
6969
*
7070
* @typedef State
7171
* @property {ReadonlyArray<string>} treeWarnings
72-
* @property {string|null} selector
72+
* @property {string} selector
7373
* @property {string|null} selectorErrorMessage
7474
* @property {boolean} showClosers
7575
* @property {boolean} showInvisible
@@ -354,9 +354,19 @@ const store = createStore(NS, {
354354
// Force print them if we have null bytes.
355355
if (store.state.html.includes('\0')) {
356356
/** @type {HTMLTextAreaElement} */ (
357-
document.getElementById('input_html')
357+
document.getElementById('input-html')
358358
).value = store.state.html;
359359
}
360+
if (store.state.contextHTML.includes('\0')) {
361+
/** @type {HTMLTextAreaElement} */ (
362+
document.getElementById('context-html')
363+
).value = store.state.contextHTML;
364+
}
365+
if (store.state.selector.includes('\0')) {
366+
/** @type {HTMLTextAreaElement} */ (
367+
document.getElementById('selector-input')
368+
).value = store.state.selector;
369+
}
360370

361371
store.render();
362372

0 commit comments

Comments
 (0)