-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
/// <reference path="./jsx.d.ts" /> | ||
|
||
export {}; | ||
/** | ||
* Configuration for the JSX runtime. | ||
*/ | ||
export const jsxConfig: JsxConfig = { | ||
jsonAttributes: ["hx-vals", "hx-headers", "data-hx-vals", "data-hx-headers"], | ||
sanitize: false, | ||
trusted: false, | ||
}; | ||
|
||
export interface JsxConfig { | ||
/** | ||
* When these attributes' values are set to object literals, they will be stringified to JSON. | ||
*/ | ||
jsonAttributes: string[]; | ||
/** | ||
* The sanitizer to be used by the runtime. | ||
* Accepts a function of the signature `(raw: string, originalType: string) => string`. | ||
* @note {@link JsxConfig.trusted} must be false for elements to be sanitized. | ||
* @see {@link Sanitizer} | ||
*/ | ||
sanitize: Sanitizer; | ||
/** | ||
* If false, value interpolations inside of JSX will be sanitized. | ||
* @note Sanitization will change the return type of JSX functions to an object that overrides `toString`. | ||
* In most cases it will function as expected, but you might sometimes need to manually coerce the JSX tree to a string. | ||
*/ | ||
trusted: boolean; | ||
} | ||
|
||
type Sanitizer = false | ((raw: string, originalType: string) => string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters