Skip to content

Commit

Permalink
capricorn86#709@trivial: Add test case to demonstrate incorrect compo…
Browse files Browse the repository at this point in the history
…sedPath for HTMLAnchorElement.
  • Loading branch information
romansp committed Feb 1, 2023
1 parent 62085eb commit 4c49907
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/happy-dom/test/event/Event.test.ts
Expand Up @@ -99,5 +99,32 @@ describe('Event', () => {
customELement.shadowRoot
]);
});

it('Returns correct composed for HTMLAnchorElement event target and composed is set to "true".', () => {
const anchor = document.createElement('a');
anchor.setAttribute('href', 'https://example.com');
let composedPath = null;

document.body.appendChild(anchor);

anchor.addEventListener('click', (event: Event) => {
composedPath = event.composedPath();
});

anchor.dispatchEvent(
new Event('click', {
bubbles: true,
composed: true
})
);

expect(composedPath).toEqual([
anchor,
document.body,
document.documentElement,
document,
window
]);
});
});
});

0 comments on commit 4c49907

Please sign in to comment.