Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
808 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var { isNodeChildrenList } = require('./utils');
|
---|
| 2 |
|
---|
| 3 | function isSafeOperator(node) {
|
---|
| 4 | return node.type === 'Operator' && node.value !== '+' && node.value !== '-';
|
---|
| 5 | }
|
---|
| 6 |
|
---|
| 7 | module.exports = function cleanWhitespace(node, item, list) {
|
---|
| 8 | // remove when first or last item in sequence
|
---|
| 9 | if (item.next === null || item.prev === null) {
|
---|
| 10 | list.remove(item);
|
---|
| 11 | return;
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | // white space in stylesheet or block children
|
---|
| 15 | if (isNodeChildrenList(this.stylesheet, list) ||
|
---|
| 16 | isNodeChildrenList(this.block, list)) {
|
---|
| 17 | list.remove(item);
|
---|
| 18 | return;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | if (item.next.data.type === 'WhiteSpace') {
|
---|
| 22 | list.remove(item);
|
---|
| 23 | return;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | if (isSafeOperator(item.prev.data) || isSafeOperator(item.next.data)) {
|
---|
| 27 | list.remove(item);
|
---|
| 28 | return;
|
---|
| 29 | }
|
---|
| 30 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.