aidando73 / bitbucket-syntax-highlighting

Add syntax highlighting to your pull requests on Bitbucket
5 stars 1 forks source link

Highlighting does not work on large PRs #28

Closed aidando73 closed 1 year ago

aidando73 commented 2 years ago
image
aidando73 commented 1 year ago

MutationObserver does not fire on file-content (on childList and subtree - probably due to how the shadow dom works).

But it does fire on attributes (on aria-label)

const allDiffsObserver = new MutationObserver((mutations) => {
  mutations
    .forEach(mutation => {
      if (mutation.type === 'attributes' && mutation.attributeName === 'aria-label') {
        highlightDiffFile(mutation.target);
      }
    });
});

E.g., the above mostly works. This works with both the arrows and individual files (but doesn't when a picture is previous photo).

One solution is to check whether the PR is a large one (e.g. search for "This is a large PR.") and then behave differently.

This also could be the more maintainable approach as the two styles behave quite differently and it'd be easier to find solutions when they're separate instead of bundled into one.