File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,20 +164,30 @@ export default {
164164 },
165165 async mounted () {
166166 await this .getContributors ()
167+
168+ // Observe the theme change.
167169 var targetNode = document .querySelector (' html' );
168170 this .theme = targetNode .className ;
171+ // Options for the observer (which mutations to observe)
169172 var config = { attributes: true , attributeFilter: [' class' ] };
170173
174+ // Callback function to execute when mutations are observed
171175 var callback = (mutationsList , observer ) => {
172176 for (let mutation of mutationsList) {
177+ // Check if the class attribute has changed.
173178 if (mutation .type === ' attributes' && mutation .attributeName === ' class' ) {
179+ // Check if class is not empty.
174180 if (mutation .target .className ) {
181+ // Set the theme to the new class.
175182 this .theme = mutation .target .className ;
176183 }
177184 }
178185 }
179186 };
187+
188+ // Create an observer instance linked to the callback function
180189 var observer = new MutationObserver (callback);
190+ // Start observing the target node for configured mutations
181191 observer .observe (targetNode, config);
182192
183193 // Scroll to the hash if it exists.
You can’t perform that action at this time.
0 commit comments