chore: Update __Query class to return null when no element is found
This commit is contained in:
parent
ad7954dbb2
commit
fba0a865dc
2 changed files with 72 additions and 64 deletions
120
data/bindata.go
120
data/bindata.go
File diff suppressed because one or more lines are too long
|
|
@ -43,12 +43,20 @@ class __Query {
|
|||
return this.elements;
|
||||
}
|
||||
|
||||
find(selector: string): __Query {
|
||||
return new __Query(this.element?.querySelector(selector) || "");
|
||||
find(selector: string): __Query | null {
|
||||
const elm = this.element?.querySelector(selector);
|
||||
if (elm) {
|
||||
return new __Query(elm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
closest(selector: string): __Query {
|
||||
return new __Query(this.element?.closest(selector) || "");
|
||||
closest(selector: string): __Query | null {
|
||||
const elm = this.element?.closest(selector);
|
||||
if (elm) {
|
||||
return new __Query(elm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
on(event: string, callback: (event: Event) => void): __Query {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue