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.
For allow lists like
elementsandattributesit 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 withelements: []or keeping all other elements by not usingelementsat all.Allow everything to be optional?
The
getmethod makes it observable is something is truly optional internally or not. While there AFAIK no observable difference between the config{ }and{ removeElements: [] }, if we treatremoveElementsas non-optional, theget()result would be{ removeElements: [] }for both.If we make
elementsandattributesoptional, 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.