Skip to content

Commit

Permalink
Add comment to PostInfo.vue
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Umer Farooq <[email protected]>
  • Loading branch information
lablnet committed Feb 2, 2024
1 parent edee852 commit b84e0ee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/PostInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,30 @@ export default {
},
async mounted() {
await this.getContributors()
// Observe the theme change.
var targetNode = document.querySelector('html');
this.theme = targetNode.className;
// Options for the observer (which mutations to observe)
var config = { attributes: true, attributeFilter: ['class'] };
// Callback function to execute when mutations are observed
var callback = (mutationsList, observer) => {
for(let mutation of mutationsList) {
// Check if the class attribute has changed.
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
// Check if class is not empty.
if (mutation.target.className) {
// Set the theme to the new class.
this.theme = mutation.target.className;
}
}
}
};
// Create an observer instance linked to the callback function
var observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
// Scroll to the hash if it exists.
Expand Down

0 comments on commit b84e0ee

Please sign in to comment.