@@ -17,8 +17,9 @@ class Pattern extends BasePattern {
1717 static trigger = ".pat-navigation" ;
1818 static parser = parser ;
1919
20+ parser_group_options = false ;
21+
2022 init ( ) {
21- this . options = parser . parse ( this . el , this . options ) ;
2223 this . $el = $ ( this . el ) ;
2324
2425 this . init_listeners ( ) ;
@@ -29,7 +30,7 @@ class Pattern extends BasePattern {
2930 * Initialize listeners for the navigation.
3031 */
3132 init_listeners ( ) {
32- const current = this . options . currentClass ;
33+ const current = this . options [ "current-class" ] ;
3334
3435 events . add_event_listener (
3536 this . el ,
@@ -74,7 +75,7 @@ class Pattern extends BasePattern {
7475 * Initial run to mark the current item and its parents.
7576 */
7677 init_markings ( ) {
77- if ( this . el . querySelector ( `.${ this . options . currentClass } ` ) ) {
78+ if ( this . el . querySelector ( `.${ this . options [ "current-class" ] } ` ) ) {
7879 log . debug ( "Mark navigation items based on existing current class" ) ;
7980 this . mark_current ( ) ;
8081 } else {
@@ -118,9 +119,9 @@ class Pattern extends BasePattern {
118119 : this . el . querySelectorAll ( `.current > a, a.current` ) ;
119120
120121 for ( const item of current_els ) {
121- item . classList . add ( this . options . currentClass ) ;
122- const wrapper = item . closest ( this . options . itemWrapper ) ;
123- wrapper ?. classList . add ( this . options . currentClass ) ;
122+ item . classList . add ( this . options [ "current-class" ] ) ;
123+ const wrapper = item . closest ( this . options [ "item-wrapper" ] ) ;
124+ wrapper ?. classList . add ( this . options [ "current-class" ] ) ;
124125 this . mark_in_path ( wrapper || item ) ;
125126 log . debug ( "Statically set current item marked as current" , item ) ;
126127 }
@@ -133,16 +134,16 @@ class Pattern extends BasePattern {
133134 *
134135 */
135136 mark_in_path ( start_el ) {
136- let path_el = this . get_parent ( start_el , this . options . itemWrapper , this . el ) ;
137+ let path_el = this . get_parent ( start_el , this . options [ "item-wrapper" ] , this . el ) ;
137138 while ( path_el ) {
138- if ( ! path_el . matches ( `.${ this . options . currentClass } ` ) ) {
139- path_el . classList . add ( this . options . inPathClass ) ;
139+ if ( ! path_el . matches ( `.${ this . options [ "current-class" ] } ` ) ) {
140+ path_el . classList . add ( this . options [ "in-path-class" ] ) ;
140141 for ( const it of [ ...path_el . children ] . filter ( ( it ) => it . matches ( "a" ) ) ) {
141- it . classList . add ( this . options . inPathClass ) ;
142+ it . classList . add ( this . options [ "in-path-class" ] ) ;
142143 }
143144 log . debug ( "Marked item as in-path" , path_el ) ;
144145 }
145- path_el = this . get_parent ( path_el , this . options . itemWrapper , this . el ) ;
146+ path_el = this . get_parent ( path_el , this . options [ "item-wrapper" ] , this . el ) ;
146147 }
147148 }
148149
@@ -166,11 +167,11 @@ class Pattern extends BasePattern {
166167 new URL ( nav_item . getAttribute ( "href" , "" ) , current_url ) ?. href
167168 ) ;
168169
169- const wrapper = nav_item . closest ( this . options . itemWrapper ) ;
170+ const wrapper = nav_item . closest ( this . options [ "item-wrapper" ] ) ;
170171
171172 if ( nav_url === current_url_prepared ) {
172- nav_item . classList . add ( this . options . currentClass ) ;
173- wrapper ?. classList . add ( this . options . currentClass ) ;
173+ nav_item . classList . add ( this . options [ "current-class" ] ) ;
174+ wrapper ?. classList . add ( this . options [ "current-class" ] ) ;
174175 this . mark_in_path ( nav_item ) ;
175176 } else if (
176177 // Compare the current navigation item url with a slash at the
@@ -180,8 +181,8 @@ class Pattern extends BasePattern {
180181 // be in the path.
181182 nav_url !== portal_url
182183 ) {
183- nav_item . classList . add ( this . options . inPathClass ) ;
184- wrapper ?. classList . add ( this . options . inPathClass ) ;
184+ nav_item . classList . add ( this . options [ "in-path-class" ] ) ;
185+ wrapper ?. classList . add ( this . options [ "in-path-class" ] ) ;
185186 } else {
186187 // Not even in path.
187188 continue ;
@@ -194,11 +195,11 @@ class Pattern extends BasePattern {
194195 */
195196 clear_items ( ) {
196197 const items = this . el . querySelectorAll (
197- `.${ this . options . inPathClass } , .${ this . options . currentClass } `
198+ `.${ this . options [ "in-path-class" ] } , .${ this . options [ "current-class" ] } `
198199 ) ;
199200 for ( const item of items ) {
200- item . classList . remove ( this . options . inPathClass ) ;
201- item . classList . remove ( this . options . currentClass ) ;
201+ item . classList . remove ( this . options [ "in-path-class" ] ) ;
202+ item . classList . remove ( this . options [ "current-class" ] ) ;
202203 }
203204 }
204205
0 commit comments