Skip to content

Commit b84e0ee

Browse files
committed
Add comment to PostInfo.vue
Signed-off-by: Muhammad Umer Farooq <umer@lablnet.com>
1 parent edee852 commit b84e0ee

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/components/PostInfo.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)