Closed
Bug 1764689
Opened 3 years ago
Closed 3 years ago
Unnecessary use of global this in BOOKMARK_VALIDATORS.url
Categories
(Toolkit :: Places, task, P3)
Toolkit
Places
Tracking
()
RESOLVED
FIXED
101 Branch
| Tracking | Status | |
|---|---|---|
| firefox101 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 file)
function simpleValidateFunc(boolValidateFn) {
return (v, input) => {
if (!boolValidateFn(v, input)) {
throw new Error("Invalid value");
}
return v;
};
}
...
const BOOKMARK_VALIDATORS = Object.freeze({
...
url: v => {
simpleValidateFunc(
val =>
(typeof val == "string" && val.length <= DB_URL_LENGTH_MAX) ||
(val instanceof Ci.nsIURI && val.spec.length <= DB_URL_LENGTH_MAX) ||
(URL.isInstance(val) && val.href.length <= DB_URL_LENGTH_MAX)
).call(this, v);
The this there is global this, but simpleValidateFunc returns an arrow function that doesn't use the this value on the call, but inherits from the enclosing scope.
| Assignee | ||
Comment 1•3 years ago
|
||
Depends on D143713
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/848dee4a3553
Remove unnnecessary global this reference in BOOKMARK_VALIDATORS.url. r=mak
Comment 3•3 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
status-firefox101:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•