Skip to content

Commit

Permalink
fix: Retain syntax highlighting when PR is updated (#30)
Browse files Browse the repository at this point in the history
e.g. when a change is pushed and user clicks reload

Co-authored-by: Aidan Do <aidan.do@nqry.com.au>
  • Loading branch information
aidando73 and Aidan Do authored Oct 13, 2022
1 parent b50f3c1 commit ef598a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions static/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const _diffFileSelector = "article[data-qa=pr-diff-file-styles]";
runWhenUrlChanges(() => {
const url = location.href;
if (url.match(/https:\/\/bitbucket.org\/.+\/.+\/pull-requests\/.+/)) {
waitForElement('section[aria-label="Diffs"]').then((diffSection) => {
// "#pull-request-details" is used instead of "section[aria-label="Diffs"]" because the latter
// is replaced with a new element when the PR is updated (e.g. when a new change is pushed and user refreshes).
waitForElement('#pull-request-details').then((diffSection) => {
allDiffsObserver.observe(diffSection, {
childList: true,
subtree: true,
Expand All @@ -13,8 +15,6 @@ runWhenUrlChanges(() => {
}
});



const allDiffsObserver = new MutationObserver((mutations) => {
mutations
.filter((mutation) => mutation.type === "childList")
Expand Down

0 comments on commit ef598a3

Please sign in to comment.