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;
|
return this.elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
find(selector: string): __Query {
|
find(selector: string): __Query | null {
|
||||||
return new __Query(this.element?.querySelector(selector) || "");
|
const elm = this.element?.querySelector(selector);
|
||||||
|
if (elm) {
|
||||||
|
return new __Query(elm);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
closest(selector: string): __Query {
|
closest(selector: string): __Query | null {
|
||||||
return new __Query(this.element?.closest(selector) || "");
|
const elm = this.element?.closest(selector);
|
||||||
|
if (elm) {
|
||||||
|
return new __Query(elm);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
on(event: string, callback: (event: Event) => void): __Query {
|
on(event: string, callback: (event: Event) => void): __Query {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue