@@ -12,16 +12,16 @@ export type ListItem = {
1212 link : string
1313}
1414
15- // Two functions that need to be implemented to use the modal
16- // When the user clicks the button, open the modal
15+ // Two functions that need to be implemented to use the modal.
16+ // When the user clicks the button, open the modal.
1717/* Click handler on the button to display it.
1818btn.onclick = function() {
1919 modal.style.display = "block";
2020}
2121
22- // When the user clicks anywhere outside of the modal, close it
23- Window click handler so that the modal will close
24- even if the user doesn't click close
22+ // When the user clicks anywhere outside of the modal, close it.
23+ // Window click handler so that the modal will close
24+ // even if the user doesn't click close.
2525window.onclick = function(event) {
2626 if (event.target == modal) {
2727 modal.style.display = "none";
@@ -70,7 +70,7 @@ const createListItems = (dom: HTMLDocument, list: ListItem) => {
7070 const link : HTMLAnchorElement = dom . createElement ( 'a' )
7171 link . setAttribute ( 'style' , modalStyles . anchorStyle )
7272 link . href = list . link
73- link . innerHTML = list . label
73+ link . textContent = list . label
7474 li . appendChild ( link )
7575 return li
7676}
@@ -84,8 +84,9 @@ const createUnOrderedList = (dom: HTMLDocument, listOfLinks: ListItem[]) => {
8484 } )
8585 return ul
8686}
87- export const createWindow = ( dom : HTMLDocument , listOfLinks : ListItem [ ] , options : ModalWidgetStyleOptions ) => {
88- const modal = createModal ( dom , options )
87+ export const createWindow = ( dom : HTMLDocument , listOfLinks : ListItem [ ] , options ?: ModalWidgetStyleOptions ) => {
88+ const modalOptions = ( options ?? { } ) as ModalWidgetStyleOptions
89+ const modal = createModal ( dom , modalOptions )
8990 const modalContent = createModalContent ( dom )
9091 const closeButton = createCloseButton ( dom )
9192 const ul = createUnOrderedList ( dom , listOfLinks )
0 commit comments