Skip to content

Commit

Permalink
fix: detect nodes added by prepend
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Mar 28, 2021
1 parent 11d9fbf commit 0b8e95d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/to-be-announced.ts
Expand Up @@ -175,6 +175,7 @@ export function register(
interceptMethod(Element.prototype, 'insertAdjacentElement', onNodeMount),
interceptMethod(Element.prototype, 'before', onNodeMount),
interceptMethod(Element.prototype, 'append', onNodeMount),
interceptMethod(Element.prototype, 'prepend', onNodeMount),
interceptMethod(Node.prototype, 'appendChild', onNodeMount),
interceptMethod(Node.prototype, 'insertBefore', onNodeMount),
interceptMethod(Node.prototype, 'replaceChild', onNodeMount),
Expand Down
10 changes: 10 additions & 0 deletions test/to-be-announced.dom.test.ts
Expand Up @@ -194,5 +194,15 @@ ASSERTIVE_CASES.forEach(({ name, value }) => {

expect('Hello world').toBeAnnounced();
});

test('should announce when content is added with `prepend`', async () => {
const parent = document.createElement('div');
appendToRoot(parent);

element.textContent = 'Hello world';
parent.prepend(element);

expect('Hello world').toBeAnnounced();
});
});
});

0 comments on commit 0b8e95d

Please sign in to comment.