Commit 0582fa2
committed
Fix undefined target element does not throw
When `assert.dom(undefined)` is called, it
incorrectly defaults to the root element instead
of throwing `TypeError: Unexpected Parameter:
undefined`. This means code like
`assert.dom(findAll('.foo')[0]).exists()` silently
passes even when `.foo` doesn't exist (because
`findAll` returns an empty array, and `array[0]`
is `undefined`).
PR#2107 changed the argument detection logic from
`arguments.length === 0` to `target !== undefined`,
which cannot distinguish between "no argument" and
passing "undefined".
This behavior was not caught by tests because
tests only used mock implementation of assert.dom.
This commit restores the original behavior that
correctly distinguishes passing no arguments and
passing undefined and adds a test to ensure
passing undefined throws an error as expected.
Addresses:
#21861 parent 3d26080 commit 0582fa2
4 files changed
Lines changed: 15 additions & 7 deletions
File tree
- packages
- qunit-dom/lib
- test-app/tests/acceptance
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
0 commit comments