first commit

This commit is contained in:
Pedro G. Galaviz
2019-11-28 20:55:32 -06:00
parent bde5ae77c1
commit 4a99a58085
63 changed files with 6227 additions and 174 deletions

View File

@@ -0,0 +1,39 @@
const BOOLEAN_ATTRIBUTES = {
disabled: true,
readonly: true,
multiple: true,
checked: true
}
// Options which should not be passed as HTML attributes
const OPTIONS_NOT_ATTRIBUTES = {
urlClass: true,
usernameClass: true,
hashtagClass: true,
usernameUrlBase: true,
hashtagUrlBase: true,
targetBlank: true,
urlTarget: true,
invisibleTagAttrs: true,
linkAttributeBlock: true,
htmlEscapeNonEntities: true,
extractUrlsWithoutProtocol: true
}
export default function (options) {
const htmlAttrs = {}
for (const k in options) {
let v = options[k]
if (OPTIONS_NOT_ATTRIBUTES[k]) {
continue
}
if (BOOLEAN_ATTRIBUTES[k]) {
v = v ? k : null
}
if (v == null) {
continue
}
htmlAttrs[k] = v
}
return htmlAttrs
}