Urara-Blog/node_modules/.pnpm-store/v3/files/d5/62ad727c752ff4b27c6046a06d3cf1343cc1d0aaedc1dffe285af159771abcf48ab3897708b7bc953128cb7443e446311270f9887635906949257915296f6e
2022-08-14 01:14:53 +08:00

31 lines
968 B
Text

function removeItemAndRedundantWhiteSpace(list, item) {
var prev = item.prev;
var next = item.next;
if (next !== null) {
if (next.data.type === 'WhiteSpace' && (prev === null || prev.data.type === 'WhiteSpace')) {
list.remove(next);
}
} else if (prev !== null && prev.data.type === 'WhiteSpace') {
list.remove(prev);
}
list.remove(item);
}
module.exports = function compressBorder(node) {
node.children.each(function(node, item, list) {
if (node.type === 'Identifier' && node.name.toLowerCase() === 'none') {
if (list.head === list.tail) {
// replace `none` for zero when `none` is a single term
item.data = {
type: 'Number',
loc: node.loc,
value: '0'
};
} else {
removeItemAndRedundantWhiteSpace(list, item);
}
}
});
};