Fix font size not being removed when pasting between fields

This commit is contained in:
Damien Elmes 2022-09-30 14:05:03 +10:00
parent de4d69454a
commit ea3b40e400

View File

@ -16,14 +16,18 @@ function filterStyling(
): (element: HTMLElement) => void {
return (element: HTMLElement): void => {
// jsdom does not support @@iterator, so manually iterate
const toRemove = [] as string[];
for (let i = 0; i < element.style.length; i++) {
const key = element.style.item(i);
const value = element.style.getPropertyValue(key);
const predicate = exceptions[key] ?? defaultPredicate;
if (!predicate(key, value)) {
element.style.removeProperty(key);
toRemove.push(key);
}
}
for (const key of toRemove) {
element.style.removeProperty(key);
}
};
}