Skip to content

Commit

Permalink
Merge branch 'noprint' into lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry committed Feb 4, 2024
2 parents 08ba62f + 614b8fe commit 12ad3ee
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
18 changes: 0 additions & 18 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@ export abstract class AstElement extends AstNode {
return text(this.childNodes, separator);
}

/** 合并相邻的文本子节点 */
normalize(): void {
const childNodes = [...this.childNodes];
for (let i = childNodes.length - 1; i >= 0; i--) {
const {type, data} = childNodes[i]!,
prev = childNodes[i - 1];
if (type !== 'text' || this.getGaps(i - 1)) {
//
} else if (data === '') {
childNodes.splice(i, 1);
} else if (prev?.type === 'text') {
prev.setAttribute('data', prev.data + data);
childNodes.splice(i, 1);
}
}
this.setAttribute('childNodes', childNodes);
}

/**
* 移除子节点
* @param i 移除位置
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export class Token extends AstElement {
str = String(firstChild);
if (length === 1 && firstChild!.type === 'text' && str.includes('\0')) {
this.replaceChildren(...this.buildFromStr(str));
this.normalize();
if (this.type === 'root') {
for (const token of this.#accum) {
token.#build();
Expand Down

0 comments on commit 12ad3ee

Please sign in to comment.