diff --git a/bridge/core/html/html_anchor_element.d.ts b/bridge/core/html/html_anchor_element.d.ts
index fa3f09e8ba..003d441ecb 100644
--- a/bridge/core/html/html_anchor_element.d.ts
+++ b/bridge/core/html/html_anchor_element.d.ts
@@ -1,6 +1,7 @@
import {Element} from "../dom/element";
+import {HTMLElement} from "./html_element";
-interface HTMLAnchorElement extends Element {
+interface HTMLAnchorElement extends HTMLElement {
target: DartImpl;
accessKey: DartImpl;
download: DartImpl;
diff --git a/integration_tests/snapshots/dom/events/event.ts.31bdc0461.png b/integration_tests/snapshots/dom/events/event.ts.31bdc0461.png
new file mode 100644
index 0000000000..3a93112cdb
Binary files /dev/null and b/integration_tests/snapshots/dom/events/event.ts.31bdc0461.png differ
diff --git a/integration_tests/specs/dom/events/event.ts b/integration_tests/specs/dom/events/event.ts
index 93397b337c..fd8dc755b2 100644
--- a/integration_tests/specs/dom/events/event.ts
+++ b/integration_tests/specs/dom/events/event.ts
@@ -786,4 +786,42 @@ describe('Event', () => {
el.style.width = '102px';
el2.style.width = '102px';
});
+
+ it('should works with preventDefault in ` element', async (done) => {
+ const anchorElement = createElement('a', {}, [createText('')]);
+ BODY.append(anchorElement);
+
+ anchorElement.addEventListener('click', async (e) => {
+ e.preventDefault();
+
+ BODY.append(createText('Nothing happened'));
+
+ await snapshot();
+ done();
+ });
+
+ anchorElement.click();
+ });
+
+ it('should satisfy react-router event check', (done) => {
+ function isModifiedEvent(event: MouseEvent) {
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
+ }
+ function shouldProcessLinkClick(event: MouseEvent) {
+ return event.button === 0 &&
+ // Let browser handle "target=_blank" etc.
+ !isModifiedEvent(event) // Ignore clicks with modifier keys
+ ;
+ }
+
+ const anchorElement = createElement('a', {}, []);
+ BODY.append(anchorElement);
+
+ anchorElement.addEventListener('click', async (e) => {
+ expect(shouldProcessLinkClick(e));
+ done();
+ });
+
+ anchorElement.click();
+ });
});
diff --git a/webf/lib/src/dom/window.dart b/webf/lib/src/dom/window.dart
index 09ea128205..c396948804 100644
--- a/webf/lib/src/dom/window.dart
+++ b/webf/lib/src/dom/window.dart
@@ -142,12 +142,6 @@ class Window extends EventTarget {
_watchedViewportElements.clear();
}
- @override
- void dispose() {
- super.dispose();
- _watchedViewportElements.clear();
- }
-
@override
void removeEventListener(String eventType, EventHandler handler, {bool isCapture = false, bool builtInCallback = false}) {
super.removeEventListener(eventType, handler, isCapture: isCapture);