| @@ -372,9 +372,9 @@ | ||
| 372 | 372 | input.addEventListener( 'input', handleSearch ); |
| 373 | 373 | input.addEventListener( 'search', handleSearch ); |
| 374 | 374 | input.addEventListener( 'change', handleSearch ); |
| 375 | 375 | |
| 376 | - function handleSearch() { | |
| 376 | + function handleSearch( event ) { | |
| 377 | 377 | const searchText = input.value.toLowerCase(); |
| 378 | 378 | const notEmptySearchText = searchText !== ''; |
| 379 | 379 | const items = Array.from( document.getElementsByClassName( targetClassName ) ); |
| 380 | 380 | |
| @@ -380,9 +380,9 @@ | ||
| 380 | 380 | |
| 381 | 381 | let foundSomething = false; |
| 382 | 382 | items.forEach( toggleSearchClassesForItem ); |
| 383 | 383 | if ( 'function' === typeof handleSearchResult ) { |
| 384 | - handleSearchResult({ foundSomething, notEmptySearchText }); | |
| 384 | + handleSearchResult({ foundSomething, notEmptySearchText }, event ); | |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | function toggleSearchClassesForItem( item ) { |
| 388 | 388 | let itemText; |
| @@ -422,9 +422,9 @@ | ||
| 422 | 422 | const listener = event => { |
| 423 | 423 | event.preventDefault(); |
| 424 | 424 | callback( event ); |
| 425 | 425 | }; |
| 426 | - element.addEventListener( 'click', listener ); | |
| 426 | + element?.addEventListener( 'click', listener ); | |
| 427 | 427 | }, |
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Does the same as jQuery( document ).on( 'event', 'selector', handler ). |
| @@ -691,8 +691,17 @@ | ||
| 691 | 691 | |
| 692 | 692 | return div({ children: [ label, input ] }); |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | + /** | |
| 696 | + * Build an element. | |
| 697 | + * | |
| 698 | + * @since 6.4.1 Accept a string as one of `children` to append a text node inside the element. | |
| 699 | + * | |
| 700 | + * @param {String} type Element tag name. | |
| 701 | + * @param {Object} args The args. | |
| 702 | + * @return {Object} | |
| 703 | + */ | |
| 695 | 704 | function tag( type, args = {}) { |
| 696 | 705 | const output = document.createElement( type ); |
| 697 | 706 | |
| 698 | 707 | if ( 'string' === typeof args ) { |
| @@ -709,9 +718,15 @@ | ||
| 709 | 718 | if ( className ) { |
| 710 | 719 | output.className = className; |
| 711 | 720 | } |
| 712 | 721 | if ( children ) { |
| 713 | - children.forEach( child => output.appendChild( child ) ); | |
| 722 | + children.forEach( child => { | |
| 723 | + if ( 'string' === typeof child ) { | |
| 724 | + output.appendChild( document.createTextNode( child ) ); | |
| 725 | + } else { | |
| 726 | + output.appendChild( child ) | |
| 727 | + } | |
| 728 | + } ); | |
| 714 | 729 | } else if ( child ) { |
| 715 | 730 | output.appendChild( child ); |
| 716 | 731 | } else if ( text ) { |
| 717 | 732 | output.textContent = text; |
| @@ -782,9 +797,10 @@ | ||
| 782 | 797 | p: [], |
| 783 | 798 | span: [ 'class' ], |
| 784 | 799 | strong: [], |
| 785 | 800 | svg: [ 'class' ], |
| 786 | - use: [] | |
| 801 | + use: [], | |
| 802 | + a: [ 'href', 'class' ] | |
| 787 | 803 | }; |
| 788 | 804 | |
| 789 | 805 | function cleanNode( node ) { |
| 790 | 806 | if ( 'undefined' === typeof node.tagName ) { |