summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorMichaelWest22 <michael@latent.nz>2024-08-30 04:30:51 +1200
committerGitHub <noreply@github.com>2024-08-29 10:30:51 -0600
commit2ba7fd280e47254016cae277521965e013e3fddd (patch)
treee7ca15fa7c65482f343b4ffc81a9f46dfec23b2d /src
parent0fd854758cd9ed7645c51240b0d34d29bddc0fbf (diff)
downloadhtmx-2ba7fd280e47254016cae277521965e013e3fddd.tar.gz
htmx-2ba7fd280e47254016cae277521965e013e3fddd.zip
Upgrade Typescript to move configuration from const to let (#2853)
* typescript upgrade v5.5.4 * fix dist
Diffstat (limited to 'src')
-rw-r--r--src/htmx.d.ts203
-rw-r--r--src/htmx.js4
2 files changed, 2 insertions, 205 deletions
diff --git a/src/htmx.d.ts b/src/htmx.d.ts
deleted file mode 100644
index 8037b2c6..00000000
--- a/src/htmx.d.ts
+++ /dev/null
@@ -1,203 +0,0 @@
-declare namespace htmx {
- const onLoad: (callback: (elt: Node) => void) => EventListener;
- const process: (elt: string | Element) => void;
- const on: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
- const off: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
- const trigger: (elt: string | EventTarget, eventName: string, detail?: any) => boolean;
- const ajax: (verb: HttpVerb, path: string, context: string | Element | HtmxAjaxHelperContext) => Promise<void>;
- const find: (eltOrSelector: string | ParentNode, selector?: string) => Element;
- const findAll: (eltOrSelector: string | ParentNode, selector?: string) => NodeListOf<Element>;
- const closest: (elt: string | Element, selector: string) => Element;
- function values(elt: Element, type: HttpVerb): any;
- const remove: (elt: Node, delay?: number) => void;
- const addClass: (elt: string | Element, clazz: string, delay?: number) => void;
- const removeClass: (node: string | Node, clazz: string, delay?: number) => void;
- const toggleClass: (elt: string | Element, clazz: string) => void;
- const takeClass: (elt: string | Node, clazz: string) => void;
- const swap: (target: string | Element, content: string, swapSpec: HtmxSwapSpecification, swapOptions?: SwapOptions) => void;
- const defineExtension: (name: string, extension: HtmxExtension) => void;
- const removeExtension: (name: string) => void;
- const logAll: () => void;
- const logNone: () => void;
- const logger: any;
- namespace config {
- const historyEnabled: boolean;
- const historyCacheSize: number;
- const refreshOnHistoryMiss: boolean;
- const defaultSwapStyle: HtmxSwapStyle;
- const defaultSwapDelay: number;
- const defaultSettleDelay: number;
- const includeIndicatorStyles: boolean;
- const indicatorClass: string;
- const requestClass: string;
- const addedClass: string;
- const settlingClass: string;
- const swappingClass: string;
- const allowEval: boolean;
- const allowScriptTags: boolean;
- const inlineScriptNonce: string;
- const inlineStyleNonce: string;
- const attributesToSettle: string[];
- const withCredentials: boolean;
- const timeout: number;
- const wsReconnectDelay: "full-jitter" | ((retryCount: number) => number);
- const wsBinaryType: BinaryType;
- const disableSelector: string;
- const scrollBehavior: 'auto' | 'instant' | 'smooth';
- const defaultFocusScroll: boolean;
- const getCacheBusterParam: boolean;
- const globalViewTransitions: boolean;
- const methodsThatUseUrlParams: (HttpVerb)[];
- const selfRequestsOnly: boolean;
- const ignoreTitle: boolean;
- const scrollIntoViewOnBoost: boolean;
- const triggerSpecsCache: any | null;
- const disableInheritance: boolean;
- const responseHandling: HtmxResponseHandlingConfig[];
- const allowNestedOobSwaps: boolean;
- }
- const parseInterval: (str: string) => number;
- const _: (str: string) => any;
- const version: string;
-}
-type HttpVerb = 'get' | 'head' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace' | 'patch';
-type SwapOptions = {
- select?: string;
- selectOOB?: string;
- eventInfo?: any;
- anchor?: string;
- contextElement?: Element;
- afterSwapCallback?: swapCallback;
- afterSettleCallback?: swapCallback;
-};
-type swapCallback = () => any;
-type HtmxSwapStyle = 'innerHTML' | 'outerHTML' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'delete' | 'none' | string;
-type HtmxSwapSpecification = {
- swapStyle: HtmxSwapStyle;
- swapDelay: number;
- settleDelay: number;
- transition?: boolean;
- ignoreTitle?: boolean;
- head?: string;
- scroll?: 'top' | 'bottom';
- scrollTarget?: string;
- show?: string;
- showTarget?: string;
- focusScroll?: boolean;
-};
-type ConditionalFunction = ((this: Node, evt: Event) => boolean) & {
- source: string;
-};
-type HtmxTriggerSpecification = {
- trigger: string;
- pollInterval?: number;
- eventFilter?: ConditionalFunction;
- changed?: boolean;
- once?: boolean;
- consume?: boolean;
- delay?: number;
- from?: string;
- target?: string;
- throttle?: number;
- queue?: string;
- root?: string;
- threshold?: string;
-};
-type HtmxElementValidationError = {
- elt: Element;
- message: string;
- validity: ValidityState;
-};
-type HtmxHeaderSpecification = Record<string, string>;
-type HtmxAjaxHelperContext = {
- source?: Element | string;
- event?: Event;
- handler?: HtmxAjaxHandler;
- target?: Element | string;
- swap?: HtmxSwapStyle;
- values?: any | FormData;
- headers?: Record<string, string>;
- select?: string;
-};
-type HtmxRequestConfig = {
- boosted: boolean;
- useUrlParams: boolean;
- formData: FormData;
- /**
- * formData proxy
- */
- parameters: any;
- unfilteredFormData: FormData;
- /**
- * unfilteredFormData proxy
- */
- unfilteredParameters: any;
- headers: HtmxHeaderSpecification;
- target: Element;
- verb: HttpVerb;
- errors: HtmxElementValidationError[];
- withCredentials: boolean;
- timeout: number;
- path: string;
- triggeringEvent: Event;
-};
-type HtmxResponseInfo = {
- xhr: XMLHttpRequest;
- target: Element;
- requestConfig: HtmxRequestConfig;
- etc: HtmxAjaxEtc;
- boosted: boolean;
- select: string;
- pathInfo: {
- requestPath: string;
- finalRequestPath: string;
- responsePath: string | null;
- anchor: string;
- };
- failed?: boolean;
- successful?: boolean;
-};
-type HtmxAjaxEtc = {
- returnPromise?: boolean;
- handler?: HtmxAjaxHandler;
- select?: string;
- targetOverride?: Element;
- swapOverride?: HtmxSwapStyle;
- headers?: Record<string, string>;
- values?: any | FormData;
- credentials?: boolean;
- timeout?: number;
-};
-type HtmxResponseHandlingConfig = {
- code?: string;
- swap: boolean;
- error?: boolean;
- ignoreTitle?: boolean;
- select?: string;
- target?: string;
- swapOverride?: string;
- event?: string;
-};
-type HtmxBeforeSwapDetails = HtmxResponseInfo & {
- shouldSwap: boolean;
- serverResponse: any;
- isError: boolean;
- ignoreTitle: boolean;
- selectOverride: string;
-};
-type HtmxAjaxHandler = (elt: Element, responseInfo: HtmxResponseInfo) => any;
-type HtmxSettleTask = (() => void);
-type HtmxSettleInfo = {
- tasks: HtmxSettleTask[];
- elts: Element[];
- title?: string;
-};
-type HtmxExtension = {
- init: (api: any) => void;
- onEvent: (name: string, event: Event | CustomEvent) => boolean;
- transformResponse: (text: string, xhr: XMLHttpRequest, elt: Element) => string;
- isInlineSwap: (swapStyle: HtmxSwapStyle) => boolean;
- handleSwap: (swapStyle: HtmxSwapStyle, target: Node, fragment: Node, settleInfo: HtmxSettleInfo) => boolean | Node[];
- encodeParameters: (xhr: XMLHttpRequest, parameters: FormData, elt: Node) => any | string | null;
- getSelectors: () => string[] | null;
-};
diff --git a/src/htmx.js b/src/htmx.js
index 6696f4b4..3ffa3829 100644
--- a/src/htmx.js
+++ b/src/htmx.js
@@ -2306,11 +2306,11 @@ var htmx = (function() {
nodeData.boosted = true
let verb, path
if (elt.tagName === 'A') {
- verb = 'get'
+ verb = (/** @type HttpVerb */('get'))
path = getRawAttribute(elt, 'href')
} else {
const rawAttribute = getRawAttribute(elt, 'method')
- verb = rawAttribute ? rawAttribute.toLowerCase() : 'get'
+ verb = (/** @type HttpVerb */(rawAttribute ? rawAttribute.toLowerCase() : 'get'))
if (verb === 'get') {
}
path = getRawAttribute(elt, 'action')