Skip to content

Commit

Permalink
Rerun extension if new blobs are appended
Browse files Browse the repository at this point in the history
  • Loading branch information
leomoty committed Aug 28, 2018
1 parent abf35f3 commit b1e63a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions e2e/automated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ describe('End to End tests', () => {
});
});
});

describe('expanded blob', () => {
it('should resolve after appending new blobs', async () => {
const url =
'https://github.com/OctoLinker/OctoLinker/pull/451/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2';
const selector = '[data-line-number="45"] + td .octolinker-link';
const expandSelector = '[data-right-range="44-55"]';

await page.goto(url);

await page.click(expandSelector);

await page.waitForSelector(selector);
});
});
});
11 changes: 11 additions & 0 deletions packages/core/octo-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,23 @@ async function run(self) {
clickHandler(matches);
}

function observeExpand(self) {
const observer = new MutationObserver(() => {
run(self);
});

for (const el of document.querySelectorAll('.diff-table tbody')) {
observer.observe(el, { childList: true });
}
}

export default class OctoLinkerCore {
constructor(options) {
initialize(this, options);
}

init() {
injection(run.bind(null, this));
observeExpand(this);
}
}

0 comments on commit b1e63a4

Please sign in to comment.