This repository was archived by the owner on Aug 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,20 @@ function nodesToArray(nodes: NodeList<HTMLElement> | HTMLCollection<HTMLElement>
44 return Array . prototype . slice . call ( nodes )
55}
66
7+ function triggerEvent ( element : HTMLElement , eventName : string , detail : Object ) {
8+ const params = { bubbles : true , cancelable : true , detail : detail || null }
9+ let event
10+
11+ if ( typeof window . CustomEvent === 'function' ) {
12+ event = new window . CustomEvent ( eventName , params )
13+ } else {
14+ event = document . createEvent ( 'CustomEvent' )
15+ event . initCustomEvent ( eventName , params . bubbles , params . cancelable , params . detail )
16+ }
17+
18+ element . dispatchEvent ( event )
19+ }
20+
721/**
822 * This models the taxonomy shown in the miller columns and the current state
923 * of it.
@@ -577,6 +591,7 @@ class MillerColumnsSelectedElement extends HTMLElement {
577591 button . textContent = 'Remove topic'
578592 button . setAttribute ( 'type' , 'button' )
579593 button . addEventListener ( 'click' , ( ) => {
594+ triggerEvent ( button , 'remove-topic' , topic )
580595 if ( this . taxonomy ) {
581596 this . taxonomy . removeTopic ( topic )
582597 }
Original file line number Diff line number Diff line change @@ -155,6 +155,11 @@ describe('miller-columns', function() {
155155
156156 const selectedItems = document . querySelector ( '#selected-items' )
157157 assert . equal ( selectedItems . textContent , 'No selected topics' )
158+
159+ const millerColumnsSelected = document . querySelector ( 'miller-columns-selected' )
160+ millerColumnsSelected . addEventListener ( 'remove-topic' , function ( e ) {
161+ assert . equal ( e . detail . topicName , "Parenting, childcare and children's services" )
162+ } )
158163 } )
159164
160165 it ( 'creates entries of selected item for adjacent topics' , function ( ) {
You can’t perform that action at this time.
0 commit comments