This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Spaceless.vue

24 lines
642 B
Vue
Raw Normal View History

2020-09-23 14:00:01 -07:00
<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>