Skip to content

Commit

Permalink
add selected attribute while initilizing multi-select
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-chitti committed Dec 11, 2023
1 parent e2bdf7f commit 00cd2dd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/multi-select/tp-multi-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ export class TPMultiSelectElement extends HTMLElement {
options.forEach( ( option: HTMLOptionElement ): void => {
const newOption: HTMLOptionElement = document.createElement( 'option' );
newOption.setAttribute( 'value', option.getAttribute( 'value' ) ?? '' );
if ( 'yes' === option.getAttribute( 'selected' ) ) {
newOption.setAttribute( 'selected', 'selected' );
}
selectElement?.append( newOption );
} );
}
Expand Down

0 comments on commit 00cd2dd

Please sign in to comment.