@aegisjsproject/sanitizer
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -9,2 +9,8 @@ # Changelog | ||
## [v0.0.5] - 2024-03-27 | ||
### Added | ||
- Add `parsers` with tagged template functions for html, css, svg, etc | ||
- Add generated minified polyfill iife script | ||
## [v0.0.4] - 2024-03-27 | ||
@@ -11,0 +17,0 @@ |
{ | ||
"name": "@aegisjsproject/sanitizer", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A polyfill for the Sanitizer API with various sanitizer configs", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
"module": "./sanitizer.js", | ||
"unpkg": "./sanitizer.js", | ||
"unpkg": "./polyfill.min.js", | ||
"exports": { | ||
@@ -88,2 +88,3 @@ ".": { | ||
"devDependencies": { | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"eslint": "^8.57.0", | ||
@@ -90,0 +91,0 @@ "http-server": "^14.1.1", |
@@ -1,2 +0,1 @@ | ||
import './polyfill.js'; | ||
export { htmlConfig, svgConfig, mathMLConfig, baseConfig, completeConfig } from './config.js'; | ||
@@ -6,1 +5,2 @@ export { normalizeConfig } from './config-utils.js'; | ||
export { HTML as HTMLNS, SVG as SVGNS, MATHML as MATHMLNS } from './namespaces.js'; | ||
export { html, css, svg, math, xml, json, text, createHTMLParser, createCSSParser } from './parsers.js'; |
@@ -1,24 +0,24 @@ | ||
import '@aegisjsproject/sanitizer/polyfill.js'; | ||
import '@aegisjsproject/sanitizer/polyfill.min.js'; | ||
import { sanitizer } from '@aegisjsproject/sanitizer/config/complete.js'; | ||
import { createHTMLParser, css } from '@aegisjsproject/sanitizer/parsers.js'; | ||
const file = new File(['This should be allowed'], 'allowed.txt', { type: 'text/plain' }); | ||
const html = createHTMLParser(sanitizer); | ||
const file = new File(['Thanks for downloading my file :)'], 'thanks.txt', { type: 'text/plain' }); | ||
Promise.all([ | ||
new CSSStyleSheet().replace(` | ||
:root { | ||
font-family: system-ui; | ||
} | ||
document.adoptedStyleSheets [css` | ||
:root { | ||
font-family: system-ui; | ||
} | ||
#nav { | ||
display: flex; | ||
gap: 0.8em; | ||
} | ||
#nav { | ||
display: flex; | ||
gap: 0.8em; | ||
} | ||
a[href], button { | ||
cursor: pointer; | ||
} | ||
`), | ||
]).then(sheets => document.adoptedStyleSheets = sheets); | ||
a[href], button { | ||
cursor: pointer; | ||
} | ||
`]; | ||
document.body.setHTML(` | ||
document.body.append(html` | ||
<style> | ||
@@ -39,3 +39,3 @@ h1::after { | ||
<a href="data:text/plain,Not%20Allowed" target="_blank"><code>data:</code> Link</a> | ||
<a href="${URL.createObjectURL(file)}" target="_blank"><code>blob:</code> Link</a> | ||
<a href="${URL.createObjectURL(file)}" download="${file.name}" target="_blank"><code>blob:</code> Download Link</a> | ||
</nav> | ||
@@ -86,4 +86,4 @@ <main id="main"></main> | ||
</template> | ||
`, { sanitizer }); | ||
`); | ||
document.getElementById('main').append(document.getElementById('tmp').content); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
146747
32
4046
4