fix(js): normalize request policies
Honor only documented request concurrency policies and fall back to default behavior for unknown data-slhx-policy values. req: convention/006
This commit is contained in:
@@ -45,8 +45,12 @@
|
||||
return raw && /^\d+$/.test(raw) ? raw : null;
|
||||
}
|
||||
|
||||
function normalizedPolicy(value) {
|
||||
return value === "latest" || value === "queue" || value === "drop" || value === "parallel" ? value : null;
|
||||
}
|
||||
|
||||
function requestPolicy(el, eventName) {
|
||||
const policy = el.getAttribute("data-slhx-policy");
|
||||
const policy = normalizedPolicy(el.getAttribute("data-slhx-policy"));
|
||||
if (policy) return policy;
|
||||
if (el.hasAttribute("data-slhx-debounce") || eventName === "input") return "latest";
|
||||
if (el.tagName === "FORM") return "drop";
|
||||
|
||||
Reference in New Issue
Block a user