This adds are new attribute to Elements, "dangerouslySetInnerHTML", which like the same attribute from React allows one to take a stirng of unescaped HTML and render it unconditionally. This is of course a potentially dangerous operation that can open your app up to XSS attacks, but for interoperating with existing content management systems and libraries that output HTML (e.g. markdown renderers). Using "dangerouslySetInnerHTML" on an element with children will generate an error within createElement, since it doesn't make sense to have both children and inner HTML.
288 lines
7.8 KiB
TypeScript
288 lines
7.8 KiB
TypeScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
import { HTMLElement } from "./component";
|
|
|
|
export interface RdfaAttributes {
|
|
about?: string;
|
|
datatype?: string;
|
|
inlist?: boolean;
|
|
prefix?: string;
|
|
property?: string;
|
|
resource?: string;
|
|
typeof?: string;
|
|
vocab?: string;
|
|
}
|
|
|
|
export interface MicrodataAttributes {
|
|
itemProp?: string;
|
|
itemScope?: boolean;
|
|
itemType?: string;
|
|
itemID?: string;
|
|
itemRef?: string;
|
|
}
|
|
|
|
export interface SetInnerHtmlAttributes {
|
|
dangerouslySetInnerHTML?: { __html: string };
|
|
}
|
|
|
|
export interface HTMLAttributes
|
|
extends RdfaAttributes,
|
|
MicrodataAttributes,
|
|
SetInnerHtmlAttributes {
|
|
accept?: string;
|
|
acceptCharset?: string;
|
|
accessKey?: string;
|
|
action?: string;
|
|
allowFullScreen?: boolean;
|
|
allowTransparency?: boolean;
|
|
alt?: string;
|
|
as?: string;
|
|
async?: boolean;
|
|
autoComplete?: string;
|
|
autoCorrect?: string;
|
|
autoFocus?: boolean;
|
|
autoPlay?: boolean;
|
|
capture?: boolean;
|
|
cellPadding?: number | string;
|
|
cellSpacing?: number | string;
|
|
charSet?: string;
|
|
challenge?: string;
|
|
checked?: boolean;
|
|
class?: string;
|
|
className?: string;
|
|
cols?: number;
|
|
colSpan?: number;
|
|
content?: string;
|
|
contentEditable?: boolean;
|
|
contextMenu?: string;
|
|
controls?: boolean;
|
|
controlsList?: string;
|
|
coords?: string;
|
|
crossOrigin?: string;
|
|
data?: string;
|
|
dateTime?: string;
|
|
default?: boolean;
|
|
defer?: boolean;
|
|
dir?: "auto" | "rtl" | "ltr";
|
|
disabled?: boolean;
|
|
disableRemotePlayback?: boolean;
|
|
download?: boolean | string;
|
|
draggable?: boolean;
|
|
encType?: string;
|
|
form?: string;
|
|
formAction?: string;
|
|
formEncType?: string;
|
|
formMethod?: string;
|
|
formNoValidate?: boolean;
|
|
formTarget?: string;
|
|
frameBorder?: number | string;
|
|
headers?: string;
|
|
height?: number | string;
|
|
hidden?: boolean;
|
|
high?: number;
|
|
href?: string;
|
|
hrefLang?: string;
|
|
for?: string;
|
|
htmlFor?: string;
|
|
httpEquiv?: string;
|
|
icon?: string;
|
|
id?: string;
|
|
inputMode?: string;
|
|
integrity?: string;
|
|
is?: string;
|
|
keyParams?: string;
|
|
keyType?: string;
|
|
kind?: string;
|
|
label?: string;
|
|
lang?: string;
|
|
list?: string;
|
|
loop?: boolean;
|
|
low?: number;
|
|
manifest?: string;
|
|
marginHeight?: number;
|
|
marginWidth?: number;
|
|
max?: number | string;
|
|
maxLength?: number;
|
|
media?: string;
|
|
mediaGroup?: string;
|
|
method?: string;
|
|
min?: number | string;
|
|
minLength?: number;
|
|
multiple?: boolean;
|
|
muted?: boolean;
|
|
name?: string;
|
|
nonce?: string;
|
|
noValidate?: boolean;
|
|
open?: boolean;
|
|
optimum?: number;
|
|
pattern?: string;
|
|
placeholder?: string;
|
|
playsInline?: boolean;
|
|
poster?: string;
|
|
preload?: string;
|
|
radioGroup?: string;
|
|
readOnly?: boolean;
|
|
rel?: string;
|
|
required?: boolean;
|
|
role?: string;
|
|
rows?: number;
|
|
rowSpan?: number;
|
|
sandbox?: string;
|
|
scope?: string;
|
|
scoped?: boolean;
|
|
scrolling?: string;
|
|
seamless?: boolean;
|
|
selected?: boolean;
|
|
shape?: string;
|
|
size?: number;
|
|
sizes?: string;
|
|
slot?: string;
|
|
span?: number;
|
|
spellcheck?: boolean;
|
|
src?: string;
|
|
srcset?: string;
|
|
srcDoc?: string;
|
|
srcLang?: string;
|
|
srcSet?: string;
|
|
start?: number;
|
|
step?: number | string;
|
|
style?: string | { [key: string]: string | number };
|
|
summary?: string;
|
|
tabIndex?: number;
|
|
target?: string;
|
|
title?: string;
|
|
type?: string;
|
|
useMap?: string;
|
|
value?: string | string[] | number;
|
|
volume?: string | number;
|
|
width?: number | string;
|
|
wmode?: string;
|
|
wrap?: string;
|
|
}
|
|
|
|
declare global {
|
|
namespace JSX {
|
|
type Element = HTMLElement;
|
|
type IntrinsicElements = {
|
|
a: HTMLAttributes;
|
|
abbr: HTMLAttributes;
|
|
address: HTMLAttributes;
|
|
area: HTMLAttributes;
|
|
article: HTMLAttributes;
|
|
aside: HTMLAttributes;
|
|
audio: HTMLAttributes;
|
|
b: HTMLAttributes;
|
|
base: HTMLAttributes;
|
|
bdi: HTMLAttributes;
|
|
bdo: HTMLAttributes;
|
|
big: HTMLAttributes;
|
|
blockquote: HTMLAttributes;
|
|
body: HTMLAttributes;
|
|
br: HTMLAttributes;
|
|
button: HTMLAttributes;
|
|
canvas: HTMLAttributes;
|
|
caption: HTMLAttributes;
|
|
cite: HTMLAttributes;
|
|
code: HTMLAttributes;
|
|
col: HTMLAttributes;
|
|
colgroup: HTMLAttributes;
|
|
data: HTMLAttributes;
|
|
datalist: HTMLAttributes;
|
|
dd: HTMLAttributes;
|
|
del: HTMLAttributes;
|
|
details: HTMLAttributes;
|
|
dfn: HTMLAttributes;
|
|
dialog: HTMLAttributes;
|
|
div: HTMLAttributes;
|
|
dl: HTMLAttributes;
|
|
dt: HTMLAttributes;
|
|
em: HTMLAttributes;
|
|
embed: HTMLAttributes;
|
|
fieldset: HTMLAttributes;
|
|
figcaption: HTMLAttributes;
|
|
figure: HTMLAttributes;
|
|
footer: HTMLAttributes;
|
|
form: HTMLAttributes;
|
|
h1: HTMLAttributes;
|
|
h2: HTMLAttributes;
|
|
h3: HTMLAttributes;
|
|
h4: HTMLAttributes;
|
|
h5: HTMLAttributes;
|
|
h6: HTMLAttributes;
|
|
head: HTMLAttributes;
|
|
header: HTMLAttributes;
|
|
hgroup: HTMLAttributes;
|
|
hr: HTMLAttributes;
|
|
html: HTMLAttributes;
|
|
i: HTMLAttributes;
|
|
iframe: HTMLAttributes;
|
|
img: HTMLAttributes;
|
|
input: HTMLAttributes;
|
|
ins: HTMLAttributes;
|
|
kbd: HTMLAttributes;
|
|
keygen: HTMLAttributes;
|
|
label: HTMLAttributes;
|
|
legend: HTMLAttributes;
|
|
li: HTMLAttributes;
|
|
link: HTMLAttributes;
|
|
main: HTMLAttributes;
|
|
map: HTMLAttributes;
|
|
mark: HTMLAttributes;
|
|
marquee: HTMLAttributes;
|
|
menu: HTMLAttributes;
|
|
menuitem: HTMLAttributes;
|
|
meta: HTMLAttributes;
|
|
meter: HTMLAttributes;
|
|
nav: HTMLAttributes;
|
|
noscript: HTMLAttributes;
|
|
object: HTMLAttributes;
|
|
ol: HTMLAttributes;
|
|
optgroup: HTMLAttributes;
|
|
option: HTMLAttributes;
|
|
output: HTMLAttributes;
|
|
p: HTMLAttributes;
|
|
param: HTMLAttributes;
|
|
picture: HTMLAttributes;
|
|
pre: HTMLAttributes;
|
|
progress: HTMLAttributes;
|
|
q: HTMLAttributes;
|
|
rp: HTMLAttributes;
|
|
rt: HTMLAttributes;
|
|
ruby: HTMLAttributes;
|
|
s: HTMLAttributes;
|
|
samp: HTMLAttributes;
|
|
script: HTMLAttributes;
|
|
section: HTMLAttributes;
|
|
select: HTMLAttributes;
|
|
slot: HTMLAttributes;
|
|
small: HTMLAttributes;
|
|
source: HTMLAttributes;
|
|
span: HTMLAttributes;
|
|
strong: HTMLAttributes;
|
|
style: HTMLAttributes;
|
|
sub: HTMLAttributes;
|
|
summary: HTMLAttributes;
|
|
sup: HTMLAttributes;
|
|
table: HTMLAttributes;
|
|
tbody: HTMLAttributes;
|
|
td: HTMLAttributes;
|
|
textarea: HTMLAttributes;
|
|
tfoot: HTMLAttributes;
|
|
th: HTMLAttributes;
|
|
thead: HTMLAttributes;
|
|
time: HTMLAttributes;
|
|
title: HTMLAttributes;
|
|
tr: HTMLAttributes;
|
|
track: HTMLAttributes;
|
|
u: HTMLAttributes;
|
|
ul: HTMLAttributes;
|
|
var: HTMLAttributes;
|
|
video: HTMLAttributes;
|
|
wbr: HTMLAttributes;
|
|
};
|
|
}
|
|
}
|