Skip to content

Commit

Permalink
Improve mutation observation
Browse files Browse the repository at this point in the history
By this change, we only capture changes in elements, not the mutation in their
attributes. This brings a slight performance boost.
  • Loading branch information
ahangarha committed Jan 25, 2024
1 parent 0395baf commit b137e1c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ const applyBidi = () => {
// Define the callback function
const processBlocks = (mutationsList) => {
mutationsList.forEach((mutation) => {
if (mutation.type !== 'childList') return;

mutation.addedNodes.forEach((addedNode) => {
if (addedNode.nodeType !== Node.ELEMENT_NODE) return;

Expand All @@ -286,7 +284,11 @@ const applyBidi = () => {
};

const observer = new MutationObserver(processBlocks);
observer.observe(graphDocument, { childList: true, subtree: true });
observer.observe(graphDocument, {
attributes: false,
childList: true,
subtree: true,
});
};

const applyCustomBidiStyle = () => {
Expand Down

0 comments on commit b137e1c

Please sign in to comment.