You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_**NOTE**: Currently, the ignore comment strategy does NOT remove comments from CSS or JavaScript embedded in `<style>` or `<script>` tags._
66
67
67
-
### Ignoring special `diff:`attributes
68
-
Any attributes that starts with `diff:` are automatically filtered out before matching/comparing happens. E.g. `diff:whitespace="..."` does not show up as a missing diff when added to an control element.
68
+
### Ignoring special "diff"-attributes
69
+
Any attributes that starts with `diff:` are automatically filtered out before matching/comparing happens. E.g. `diff:whitespace="..."` does not show up as a missing diff when added to an control element.
69
70
70
71
To enable this option, use the `IgnoreDiffAttributes()` method on the `DiffBuilder` class, e.g.:
71
72
@@ -161,7 +162,7 @@ The following control node will be compared against the `<h1>` in the `<header>`
161
162
162
163
One use case of the CSS-selector element matcher is where you only want to test one part of a sub-tree, and ignore the rest. The example above will report the unmatched test nodes as *unexpected*, but those "diffs" can be ignored, since that is expected. This approach can save you from specifying all the needed control nodes, if only part of a sub tree needs to be compared.
163
164
164
-
To choose this matcher, use the `WithSearchingMatcher()` method on the `DiffBuilder` class, e.g.:
165
+
To choose this matcher, use the `WithCssSelectorMatcher()` method on the `DiffBuilder` class, e.g.:
165
166
166
167
```csharp
167
168
vardiffs=DiffBuilder
@@ -174,28 +175,26 @@ var diffs = DiffBuilder
174
175
### Attribute matching strategies
175
176
These are the built-in attribute matching strategies.
176
177
177
-
#### One-to-one attribute name matcher
178
+
#### Attribute name matcher
178
179
This selector will match attributes on a control element with attributes on a test element using the attribute's name. If an *control* attribute is not matched, it is reported as *missing* and if a *test* attribute is not matched, it is reported as *unexpected*.
179
180
180
-
To choose this matcher, use the `WithOneToOneAttributeMatcher()` method on the `DiffBuilder` class, e.g.:
181
+
To choose this matcher, use the `WithAttributeNameMatcher()` method on the `DiffBuilder` class, e.g.:
181
182
182
183
```csharp
183
184
vardiffs=DiffBuilder
184
185
.Compare(controlHtml)
185
186
.WithTest(testHtml)
186
-
.WithOneToOneAttributeMatcher()
187
+
.WithAttributeNameMatcher()
187
188
.Build();
188
189
```
189
190
190
-
**Note:** this matcher will not count any diff-`:postfix` modifiers on attributes as part of the name when matching, thus, `id:regex="..."` will be matched with `id="..."`.
191
-
192
191
## Comparing strategies
193
192
These are the built-in comparing strategies.
194
193
195
-
### Node compare strategy
194
+
### Node and element compare strategy
196
195
The basic node compare strategy will simply check if the node's types and node's name are equal.
197
196
198
-
To choose this matcher, use the `WithNodeNameComparer()` method on the `DiffBuilder` class, e.g.:
197
+
To choose this comparer, use the `WithNodeNameComparer()` method on the `DiffBuilder` class, e.g.:
199
198
200
199
```csharp
201
200
vardiffs=DiffBuilder
@@ -205,7 +204,7 @@ var diffs = DiffBuilder
205
204
.Build();
206
205
```
207
206
208
-
### Ignore attribute
207
+
### Ignore element attribute
209
208
If the `diff:ignore="true"` attribute is used on a control element (`="true"` implicit/optional), all their attributes and child nodes are skipped/ignored during comparison, including those of the test element, the control element is matched with.
210
209
211
210
In this example, the `<h1>` tag, it's attribute and children are considered the same as the element it is matched with:
@@ -216,13 +215,13 @@ In this example, the `<h1>` tag, it's attribute and children are considered the
216
215
</header>
217
216
```
218
217
219
-
Activate this strategy by calling the `EnableIgnoreAttribute()` method on a `DiffBuilder` instance, e.g.:
218
+
Activate this strategy by calling the `WithIgnoreElementSupport()` method on a `DiffBuilder` instance, e.g.:
220
219
221
220
```csharp
222
221
vardiffs=DiffBuilder
223
222
.Compare(controlHtml)
224
223
.WithTest(testHtml)
225
-
.EnableIgnoreAttribute()
224
+
.WithIgnoreElementSupport()
226
225
.Build();
227
226
```
228
227
@@ -265,13 +264,13 @@ To configure/override whitespace rules on a specific subtree in the comparison,
265
264
**NOTE:** It is on the issues list to deal with whitespace properly inside `<style>` and `<script>`-tags, e.g. inside strings.
266
265
267
266
#### Perform case-_insensitve_ text comparison
268
-
To compare the text in two text nodes to each other using a case-insensitive comparison, call the `WithTextComparer(WhitespaceOption, ignoreCase: true)` method on a `DiffBuilder` instance, e.g.:
267
+
To compare the text in two text nodes to each other using a case-insensitive comparison, call the `WithTextComparer(ignoreCase: true)` method on a `DiffBuilder` instance, e.g.:
@@ -296,25 +295,6 @@ By using the inline attribute `diff:regex` on the element containing the text no
296
295
297
296
The above control text would use case-insensitive regular expression to match against a test text string (e.g. "HELLO WORLD 2020").
298
297
299
-
### Ignore postfix for attributes
300
-
To ignore a specific attribute during comparison, add the `:ignore` postfix to the attribute on the control element. Thus will simply skip comparing the two attributes and not report any differences between them. E.g. to ignore the `class` attribute, do:
301
-
302
-
```html
303
-
<header>
304
-
<h1class:ignore="heading-1">Hello world</h1>
305
-
</header>
306
-
```
307
-
308
-
Activate this strategy by calling the `EnableIgnoreAttribute()` method on a `DiffBuilder` instance, e.g.:
309
-
310
-
```csharp
311
-
vardiffs=DiffBuilder
312
-
.Compare(controlHtml)
313
-
.WithTest(testHtml)
314
-
.EnableIgnoreAttribute()
315
-
.Build();
316
-
```
317
-
318
298
### Attribute Compare options
319
299
The library supports various ways to perform attribute comparison.
320
300
@@ -325,7 +305,15 @@ The *"name and value comparison"* is the base comparison option, and that will t
325
305
-`attr="foo"` is the NOT same as `attr="bar"`
326
306
-`foo="attr"` is the NOT same as `bar="attr"`
327
307
328
-
This comparison mode is on by default.
308
+
To choose this comparer, use the `WithAttributeComparer()` method on the `DiffBuilder` class, e.g.:
309
+
310
+
```csharp
311
+
vardiffs=DiffBuilder
312
+
.Compare(controlHtml)
313
+
.WithTest(testHtml)
314
+
.WithAttributeComparer()
315
+
.Build();
316
+
```
329
317
330
318
#### RegEx attribute value comparer
331
319
It is possible to specify a regular expression in the control attributes value, and add the `:regex` postfix to the *control* attributes name, to have the comparison performed using a Regex match test. E.g.
To ignore a specific attribute during comparison, add the `:ignore` postfix to the attribute on the control element. Thus will simply skip comparing the two attributes and not report any differences between them. E.g. to ignore the `class` attribute, do:
373
+
374
+
```html
375
+
<header>
376
+
<h1class:ignore="heading-1">Hello world</h1>
377
+
</header>
378
+
```
379
+
380
+
Activate this strategy by calling the `WithInlineAttributeIgnoreSupport()` method on a `DiffBuilder` instance, e.g.:
/// Specialized comparers always execute after any generalized comparers in the pipeline.
117
+
/// That enables them to correct for the generic comparers decision.
118
+
/// </summary>
119
+
/// <param name="compareStrategy"></param>
120
+
/// <param name="isSpecializedComparer">true if <paramref name="compareStrategy"/> is a specialized comparer, false if it is a generalized comparer</param>
/// Specialized comparers always execute after any generalized comparers in the pipeline.
132
+
/// That enables them to correct for the generic comparers decision.
133
+
/// </summary>
134
+
/// <param name="compareStrategy"></param>
135
+
/// <param name="isSpecializedComparer">true if <paramref name="compareStrategy"/> is a specialized comparer, false if it is a generalized comparer</param>
0 commit comments