u2ui 1.5.12 → 1.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,8 @@ repairs editable document shape.
|
|
|
13
13
|
- `elements`: element names the security policy can accept;
|
|
14
14
|
- `attributes`: global (`*`) and per-element attribute names;
|
|
15
15
|
- `protocols`: per-element rules for URL attributes;
|
|
16
|
-
- `drop`: element names that `narrow()` removes with their content
|
|
16
|
+
- `drop`: element names that `narrow()` removes with their content, before it
|
|
17
|
+
asks `skip` — no later stage may be left holding them;
|
|
17
18
|
- `comments` and `dataAttributes`: explicit booleans, both false by default.
|
|
18
19
|
|
|
19
20
|
An element outside `elements` keeps its content — dropping it would lose text the
|
|
@@ -85,6 +85,8 @@ export class SanitizePolicy {
|
|
|
85
85
|
// `skip` leaves an element to a later stage. Structural repair already
|
|
86
86
|
// removes what the content model rejects, and it does so knowing that
|
|
87
87
|
// dissolving a block into inline content needs a line break to survive.
|
|
88
|
+
// A `drop` element is not that kind of question — no later stage may keep
|
|
89
|
+
// its content — so it goes before `skip` is asked.
|
|
88
90
|
//
|
|
89
91
|
// `alias` names an equivalent for an element that is not allowed. Dropping
|
|
90
92
|
// `<b>` would lose the emphasis it carries, so a strict list can still keep
|
|
@@ -96,15 +98,14 @@ export class SanitizePolicy {
|
|
|
96
98
|
: this.elements.filter(name => elements.includes(name));
|
|
97
99
|
const changed = [];
|
|
98
100
|
for (const element of descendants(root).reverse()) {
|
|
99
|
-
if (preserve?.has(element)) continue;
|
|
100
|
-
if (!element.parentNode || skip?.(element)) continue;
|
|
101
|
+
if (preserve?.has(element) || !element.parentNode) continue;
|
|
101
102
|
if (this.drop.includes(element.localName)) {
|
|
102
103
|
if (map) map.remove(element);
|
|
103
104
|
else element.remove();
|
|
104
105
|
changed.push(element);
|
|
105
106
|
continue;
|
|
106
107
|
}
|
|
107
|
-
if (allowed.includes(element.localName)) continue;
|
|
108
|
+
if (skip?.(element) || allowed.includes(element.localName)) continue;
|
|
108
109
|
const equivalent = alias?.[element.localName];
|
|
109
110
|
if (equivalent && allowed.includes(equivalent)) {
|
|
110
111
|
const replacement = element.ownerDocument.createElement(equivalent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "u2ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.13",
|
|
4
4
|
"description": "HTML Advanced: More Capabilities, Same Feel, Same Simplicity",
|
|
5
5
|
"keywords": ["web-components","pattern-library","component-library","ui-toolkit","design-system"],
|
|
6
6
|
"author": "Tobias Buschor",
|