overwrite -> update

pull/8339/head
Ben McCann 4 years ago
parent 0ce8177387
commit b194b23c47

@ -76,7 +76,7 @@ export default class Selector {
this.blocks.forEach((block, i) => { this.blocks.forEach((block, i) => {
if (i > 0) { if (i > 0) {
if (block.start - c > 1) { if (block.start - c > 1) {
code.overwrite(c, block.start, block.combinator.name || ' '); code.update(c, block.start, block.combinator.name || ' ');
} }
} }
@ -112,7 +112,7 @@ export default class Selector {
} }
if (selector.type === 'TypeSelector' && selector.name === '*') { if (selector.type === 'TypeSelector' && selector.name === '*') {
code.overwrite(selector.start, selector.end, attr); code.update(selector.start, selector.end, attr);
} else { } else {
code.appendLeft(selector.end, attr); code.appendLeft(selector.end, attr);
} }

@ -35,7 +35,7 @@ function minify_declarations(
declarations.forEach((declaration, i) => { declarations.forEach((declaration, i) => {
const separator = i > 0 ? ';' : ''; const separator = i > 0 ? ';' : '';
if ((declaration.node.start - c) > separator.length) { if ((declaration.node.start - c) > separator.length) {
code.overwrite(c, declaration.node.start, separator); code.update(c, declaration.node.start, separator);
} }
declaration.minify(code); declaration.minify(code);
c = declaration.node.end; c = declaration.node.end;
@ -75,7 +75,7 @@ class Rule {
if (selector.used) { if (selector.used) {
const separator = started ? ',' : ''; const separator = started ? ',' : '';
if ((selector.node.start - c) > separator.length) { if ((selector.node.start - c) > separator.length) {
code.overwrite(c, selector.node.start, separator); code.update(c, selector.node.start, separator);
} }
selector.minify(code); selector.minify(code);
@ -133,7 +133,7 @@ class Declaration {
if (block.type === 'Identifier') { if (block.type === 'Identifier') {
const name = block.name; const name = block.name;
if (keyframes.has(name)) { if (keyframes.has(name)) {
code.overwrite(block.start, block.end, keyframes.get(name)); code.update(block.start, block.end, keyframes.get(name));
} }
} }
}); });
@ -156,7 +156,7 @@ class Declaration {
while (regex_whitespace.test(code.original[start])) start += 1; while (regex_whitespace.test(code.original[start])) start += 1;
if (start - c > 1) { if (start - c > 1) {
code.overwrite(c, start, ':'); code.update(c, start, ':');
} }
} }
} }
@ -204,7 +204,7 @@ class Atrule {
code.remove(c, this.node.block.start); code.remove(c, this.node.block.start);
} else if (this.node.name === 'supports') { } else if (this.node.name === 'supports') {
let c = this.node.start + 9; let c = this.node.start + 9;
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' '); if (this.node.prelude.start - c > 1) code.update(c, this.node.prelude.start, ' ');
this.node.prelude.children.forEach((query: CssNode) => { this.node.prelude.children.forEach((query: CssNode) => {
// TODO minify queries // TODO minify queries
c = query.end; c = query.end;
@ -213,7 +213,7 @@ class Atrule {
} else { } else {
let c = this.node.start + this.node.name.length + 1; let c = this.node.start + this.node.name.length + 1;
if (this.node.prelude) { if (this.node.prelude) {
if (this.node.prelude.start - c > 1) code.overwrite(c, this.node.prelude.start, ' '); if (this.node.prelude.start - c > 1) code.update(c, this.node.prelude.start, ' ');
c = this.node.prelude.end; c = this.node.prelude.end;
} }
if (this.node.block && this.node.block.start - c > 0) { if (this.node.block && this.node.block.start - c > 0) {
@ -255,7 +255,7 @@ class Atrule {
}); });
}); });
} else { } else {
code.overwrite(start, end, keyframes.get(name)); code.update(start, end, keyframes.get(name));
} }
} }
}); });

Loading…
Cancel
Save