5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 23:11:42 +00:00

limpiar cosas mejor

This commit is contained in:
void 2020-11-16 17:06:47 -03:00
parent cc0dcf47a7
commit accf2d7b80

View file

@ -279,6 +279,9 @@ function fixContent (contentEl) {
* * Junta nodos de texto que están al lado
* * Junta nodos de la misma "mark" que están al lado
* * Borra elementos sin contenido (ver `hasContent`) y no están seleccionados
* * Borra inline styles no autorizados
* * Borra propiedades de IMG no autorizadas
* * Borra <FONT> y <STYLE>
*/
function cleanNode (node, contentEl) {
for (const child of node.childNodes) {
@ -320,6 +323,30 @@ function cleanNode (node, contentEl) {
&& parentEl.tagName !== "OL"
)
moveChildren(child, parentEl, child.nextSibling)
} else if (child.tagName === "IMG") {
if (child.getAttribute("width")) child.removeAttribute("width")
if (child.getAttribute("height")) child.removeAttribute("height")
if (child.getAttribute("vspace")) child.removeAttribute("vspace")
if (child.getAttribute("hspace")) child.removeAttribute("hspace")
if (child.align.length) child.removeAttribute("align")
if (child.name.length) child.removeAttribute("name")
if (!child.src.length) child.src = "https://radio.sutty.nl/public/placeholder_992x992.png"
} else if (child.tagName === "FONT") {
moveChildren(child, child.parentElement, child.nextSiling)
child.parentElement.removeChild(child)
return
} else if (child.tagName === "STYLE") {
child.parentElement.removeChild(child)
return
}
for (const style of Object.values(child.style)) {
const value = child.style[style]
switch (style) {
default:
child.style[style] = ""
}
}
}
cleanNode(child, contentEl)