1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-08 06:36:33 +02:00

Add js-docs shortcode to ensure consistency between doc and js code (#38316)

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Hannah Issermann
2023-03-27 11:10:25 +02:00
committed by GitHub
parent 31f93e2aff
commit 06f7c3b6c7
7 changed files with 56 additions and 92 deletions

View File

@@ -16,8 +16,6 @@ const uriAttributes = new Set([
'xlink:href'
])
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
/**
* A pattern that recognizes a commonly useful subset of URLs that are safe.
*
@@ -48,6 +46,9 @@ const allowedAttribute = (attribute, allowedAttributeList) => {
.some(regex => regex.test(attributeName))
}
// js-docs-start allow-list
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
export const DefaultAllowlist = {
// Global attributes allowed on any supplied element below.
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
@@ -81,6 +82,7 @@ export const DefaultAllowlist = {
u: [],
ul: []
}
// js-docs-end allow-list
export function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
if (!unsafeHtml.length) {