Skip to content

Commit

Permalink
docs: add diff:ignoreChildren and diff:ignoreAttributes description
Browse files Browse the repository at this point in the history
  • Loading branch information
egil authored Jan 27, 2022
1 parent 2c1a1c1 commit dd3196d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/site/docs/verification/semantic-html-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ Here are the customization options you have available to you:
</header>
```

- **Ignore children:** Use the `diff:ignoreChildren` attribute (no value is needed) to ignore all child nodes/elements of an element. This does not include attributes. For example, to ignore all child nodes of the `h1` element, do the following:

```html
<header>
<h1 diff:ignoreChildren>Hello <span>world</span></h1>
</header>
```

- **Ignore all attributes:** Use the `diff:ignoreAttributes` attribute (no value is needed) to ignore all attributes of an element. For example:

```html
<header>
<h1 diff:ignoreAttributes>Hello world</h1>
</header>
```

> [!NOTE]
> The `diff:ignoreChildren` and `diff:ignoreAttributes` attributes can be combined to ignore all child nodes/element *and* attributes of an element, but still verify that the element itself exists. For example:
```html
<header>
<h1 diff:ignoreChildren diff:ignoreAttributes>Hello world</h1>
</header>

- **Configure whitespace handling:** By default, all nodes and elements are compared using the `Normalize` whitespace handling option. The `Normalize` option will trim all text nodes and replace two or more whitespace characters with a single space character. The other options are `Preserve`, which will leave all whitespace unchanged, and `RemoveWhitespaceNodes`, which will only remove empty text nodes.

To override the default option, use the `diff:whitespace` attribute, and pass one of the three options to it. For example:
Expand Down

0 comments on commit dd3196d

Please sign in to comment.