Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c469791

Browse files
authored
[web:tests] switch to new HTML DOM matcher (#52354)
Remove the over-architected and under-utilized `canonicalizeHtml` and `HtmlComparisonMode`. Replace with a new `hasHtml` matcher. The new matcher produces considerably better error messages when matching fails (see `matchers_test.dart` for multiple examples). It also allows focusing on particular parts of the DOM rather than looking for a full match. This way a test can test just the functionality it cares about, and it can skip specifying what unrelated parts should look like (i.e. it prevents over-testing). For example, let's say you want to test that an `<flt-semantics>` element has an `aria-label` attribute. You can use a DOM pattern that specified just that: ``` expect( element, hasHtml('<flt-semantics aria-label="hello"></flt-semantics>'), ) ``` This will check for the existence of `<flt-semantics>` and `aria-label="hello"`. It will ignore everything else that's unrelated to ARIA labels. For example, the element may have its geometry specified in the `style` attribute, an `id` attribute, and many other things, but if the test doesn't care, it doesn't need to specify those things (it can, if needs to though). This also applies to `style` properties. See more examples in the `matchers_test.dart` file.
1 parent cac3b87 commit c469791

File tree

7 files changed

+598
-252
lines changed

7 files changed

+598
-252
lines changed

lib/web_ui/lib/src/engine/dom.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ extension DomElementExtension on DomElement {
597597
external set _id(JSString id);
598598
set id(String id) => _id = id.toJS;
599599

600-
@JS('innerHtml')
601-
external set _innerHtml(JSString? html);
602-
set innerHtml(String? html) => _innerHtml = html?.toJS;
600+
@JS('innerHTML')
601+
external set _innerHTML(JSString? html);
602+
set innerHTML(String? html) => _innerHTML = html?.toJS;
603603

604604
@JS('outerHTML')
605605
external JSString? get _outerHTML;

0 commit comments

Comments
 (0)