Skip to content

Handling of omitted vs empty lists #268

@evilpie

Description

@evilpie

For allow lists like elements and attributes it probably makes sense to handle an empty list differently from an entirely missing list.

Example

setHTML("<b>b</b><i>i</i>", { removeElements: ["i"] }) should probably result in <i>i</i>,
while setHTML("<b>b</b><i>i</i>", { removeElements: ["i"], elements: [] }) results in an empty string.

After #261 is fixed, the Sanitizer could be used to flatten specific elements with replaceWithChildrenElements, while either removing all other elements with elements: [] or keeping all other elements by not using elements at all.

Allow everything to be optional?

The get method makes it observable is something is truly optional internally or not. While there AFAIK no observable difference between the config { } and { removeElements: [] }, if we treat removeElements as non-optional, the get() result would be { removeElements: [] } for both.
If we make elements and attributes optional, we might consider also making those optional. I don't have a strong opinion either way.

Alternative

We could also treat elements: [] as being optional, but I think that would make the Sanitizer strictly less powerful.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions