1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/csso/lib/clean/WhiteSpace.js

31 lines
808 B
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
var { isNodeChildrenList } = require('./utils');
function isSafeOperator(node) {
return node.type === 'Operator' && node.value !== '+' && node.value !== '-';
}
2023-12-18 13:12:25 +08:00
module.exports = function cleanWhitespace(node, item, list) {
// remove when first or last item in sequence
if (item.next === null || item.prev === null) {
list.remove(item);
return;
}
2024-01-16 21:26:16 +08:00
// white space in stylesheet or block children
if (isNodeChildrenList(this.stylesheet, list) ||
isNodeChildrenList(this.block, list)) {
list.remove(item);
return;
}
if (item.next.data.type === 'WhiteSpace') {
2023-12-18 13:12:25 +08:00
list.remove(item);
return;
}
2024-01-16 21:26:16 +08:00
if (isSafeOperator(item.prev.data) || isSafeOperator(item.next.data)) {
2023-12-18 13:12:25 +08:00
list.remove(item);
return;
}
};