Skip to content

Commit

Permalink
element-to-string: Add null support
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Feb 2, 2020
1 parent c89efea commit b117d1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 1 addition & 7 deletions lib/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1217,12 +1217,6 @@ export default class DOMAssertions {
* @private
*/
private get targetDescription(): string {
if (typeof this.target === 'string') {
return this.target;
} else if (this.target instanceof Element) {
return elementToString(this.target);
} else {
return '<not found>';
}
return elementToString(this.target);
}
}
4 changes: 3 additions & 1 deletion lib/helpers/element-to-string.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// imported from https://github.com/nathanboktae/chai-dom

export default function elementToString(el: Element | NodeList | string): string {
export default function elementToString(el: Element | NodeList | string | null): string {
if (!el) return '<not found>';

let desc: string;
if (el instanceof NodeList) {
if (el.length === 0) {
Expand Down

0 comments on commit b117d1e

Please sign in to comment.