PronounsPage/components/Spaceless.vue
2020-09-23 23:00:01 +02:00

24 lines
642 B
Vue

<template>
<span><slot></slot></span>
</template>
<script>
export default {
mounted() {
this.removeWhitespaces(this.$el);
},
methods: {
removeWhitespaces(parent) {
for (let child of parent.childNodes) {
if (child.nodeName === '#text' && child.textContent.trim() === '') {
parent.removeChild(child);
}
for (let grandchild of child.childNodes) {
this.removeWhitespaces(grandchild);
}
}
}
},
}
</script>