From 4d9a442c243028f4014f5528764c08dcd608af45 Mon Sep 17 00:00:00 2001 From: MeAkib Date: Fri, 23 Oct 2026 09:18:56 +0600 Subject: [PATCH] refactor(cdk/testing): remove msMatchesSelector fallback Removes the fallback to the IE-only `msMatchesSelector` in the TestBed and Selenium WebDriver test elements, since `Element.matches` is supported in every browser we support. The deprecated Protractor test element is left unchanged. --- .../selenium-webdriver/selenium-web-driver-element.ts | 6 +----- src/cdk/testing/testbed/unit-test-element.ts | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts b/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts index 7529384c45d1..588a888ed61c 100644 --- a/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts +++ b/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts @@ -245,11 +245,7 @@ export class SeleniumWebDriverElement implements TestElement { async matchesSelector(selector: string): Promise { await this._stabilize(); return this._executeScript( - (element: Element, s: string) => - (Element.prototype.matches || (Element.prototype as any).msMatchesSelector).call( - element, - s, - ), + (element: Element, s: string) => element.matches(s), this.element(), selector, ); diff --git a/src/cdk/testing/testbed/unit-test-element.ts b/src/cdk/testing/testbed/unit-test-element.ts index 9edb55433497..b4f6227b5fba 100644 --- a/src/cdk/testing/testbed/unit-test-element.ts +++ b/src/cdk/testing/testbed/unit-test-element.ts @@ -266,11 +266,7 @@ export class UnitTestElement implements TestElement { /** Checks whether this element matches the given selector. */ async matchesSelector(selector: string): Promise { await this._stabilize(); - const elementPrototype = Element.prototype as any; - return (elementPrototype['matches'] || elementPrototype['msMatchesSelector']).call( - this.element, - selector, - ); + return this.element.matches(selector); } /** Checks whether the element is focused. */