Skip to content

Commit b057a82

Browse files
committed
Try esc escaping
1 parent f57cf3d commit b057a82

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/wp-includes/blocks/categories.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
103103
<script>
104104
( function() {
105105
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
106-
function onCatChange() {
106+
function onCatChange(e) {
107+
if ( 'keyup' === e.type && 'Escape' !== e.key ) {
108+
return;
109+
}
107110
if ( dropdown.options[ dropdown.selectedIndex ].value !== -1 ) {
108111
location.href = "<?php echo esc_url( home_url() ); ?>/?" + dropdown.name + '=' + dropdown.options[ dropdown.selectedIndex ].value;
109112
}
110113
}
111-
dropdown.onchange = onCatChange;
114+
dropdown.addEventListener( 'change', onCatChange(e) );
112115
})();
113116
</script>
114117
<?php

src/wp-includes/widgets/class-wp-widget-categories.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ public function widget( $args, $instance ) {
9797

9898
<script>
9999
(function() {
100-
var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
101-
function onCatChange() {
100+
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
101+
function onCatChange(e) {
102+
if ( 'keyup' === e.type && 'Escape' !== e.key ) {
103+
return;
104+
}
102105
if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
103106
dropdown.parentNode.submit();
104107
}
105108
}
106-
dropdown.onchange = onCatChange;
109+
dropdown.addEventListener( 'change', onCatChange(e) );
107110
})();
108111
</script>
109112

0 commit comments

Comments
 (0)