File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -119,13 +119,24 @@ onDOMContentLoaded(() => {
119119 const target = event . target as HTMLElement
120120 const targetItem = target . closest ( SELECTOR_NAV_ITEM ) as HTMLElement | undefined
121121 const targetLink = target . closest ( SELECTOR_NAV_LINK ) as HTMLAnchorElement | undefined
122+ const lteToggleElement = event . currentTarget as HTMLElement
122123
123124 if ( target ?. getAttribute ( 'href' ) === '#' || targetLink ?. getAttribute ( 'href' ) === '#' ) {
124125 event . preventDefault ( )
125126 }
126127
127128 if ( targetItem ) {
128- const data = new Treeview ( targetItem , Default )
129+ // Read data attributes
130+ const accordionAttr = lteToggleElement . dataset . accordion
131+ const animationSpeedAttr = lteToggleElement . dataset . animationSpeed
132+
133+ // Build config from data attributes, fallback to Default
134+ const config : Config = {
135+ accordion : accordionAttr === undefined ? Default . accordion : accordionAttr === 'true' ,
136+ animationSpeed : animationSpeedAttr === undefined ? Default . animationSpeed : Number ( animationSpeedAttr )
137+ }
138+
139+ const data = new Treeview ( targetItem , config )
129140 data . toggle ( )
130141 }
131142 } )
You can’t perform that action at this time.
0 commit comments