Skip to content

Commit d20f567

Browse files
committed
Use functions consistently
1 parent 8fc7fee commit d20f567

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,18 @@ function onSelectChange(event) {
121121
}
122122
}, 250 );
123123
}
124-
dropdown.addEventListener( 'keyup', function(event) {
124+
function onKeyUp( event ) {
125125
if ( 'Escape' === event.key ) {
126126
dropdown.dataset.lastkey = 'escape';
127127
} else {
128128
delete dropdown.dataset.lastkey;
129129
}
130-
});
131-
dropdown.addEventListener( 'click', function() {
130+
}
131+
function onClick() {
132132
delete dropdown.dataset.lastkey;
133-
});
133+
}
134+
dropdown.addEventListener( 'keyup', onKeyUp );
135+
dropdown.addEventListener( 'click', onClick );
134136
dropdown.addEventListener( 'change', onSelectChange );
135137
})( <?php echo wp_json_encode( $dropdown_id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
136138
</script>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ function onCatChange(event) {
108108
}
109109
}, 250 );
110110
}
111-
dropdown.addEventListener( 'keyup', function(e) {
111+
function onKeyUp( event ) {
112112
if ( 'Escape' === event.key ) {
113113
dropdown.dataset.lastkey = 'escape';
114114
} else {
115115
delete dropdown.dataset.lastkey;
116116
}
117-
});
118-
dropdown.addEventListener( 'click', function() {
117+
}
118+
function onClick() {
119119
delete dropdown.dataset.lastkey;
120-
});
120+
}
121+
dropdown.addEventListener( 'keyup', onKeyUp );
122+
dropdown.addEventListener( 'click', onClick );
121123
dropdown.addEventListener( 'change', onCatChange );
122124
})( <?php echo wp_json_encode( $dropdown_id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
123125
</script>

0 commit comments

Comments
 (0)