UNPKG

vue-remove-whitespace

Version:

A set of reusable remove whitespace directives for reusable Vue.js components

30 lines (29 loc) 774 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mixin = exports.removeWhitespace = exports.version = void 0; exports.version = '2.0.0'; function isText(node) { return node.nodeType === Node.TEXT_NODE; } function trimText(node) { Array.from(node).forEach(function (node) { if (isText(node) && node.textContent) { node.textContent = node.textContent.trim(); return; } trimText(node.childNodes); }); } exports.removeWhitespace = { inserted: function (el) { trimText(el.childNodes); }, componentUpdated: function (el) { trimText(el.childNodes); }, }; exports.mixin = { directives: { removeWhitespace: exports.removeWhitespace, }, };