Skip to content

Commit e3bc4bc

Browse files
committed
perf: convert empty text nodes to comments
1 parent cd95654 commit e3bc4bc

File tree

2 files changed

+4
-4
lines changed
  • src/runtime/internal
  • test/runtime/samples/raw-mustache-inside-head

2 files changed

+4
-4
lines changed

src/runtime/internal/dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function space() {
5454
}
5555

5656
export function empty() {
57-
return text('');
57+
return document.createComment('');
5858
}
5959

6060
export function listen(node: EventTarget, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | EventListenerOptions) {

test/runtime/samples/raw-mustache-inside-head/_config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ export default {
33
const btn = target.querySelector("button");
44
const clickEvent = new window.MouseEvent("click");
55

6-
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><style>body { color: green; }</style>'), true);
6+
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><!----><style>body { color: green; }</style>'), true);
77

88
await btn.dispatchEvent(clickEvent);
99

10-
assert.equal(window.document.head.innerHTML.includes('<style>body { color: red; }</style><style>body { color: green; }</style>'), true);
10+
assert.equal(window.document.head.innerHTML.includes('<style>body { color: red; }</style><!----><style>body { color: green; }</style>'), true);
1111

1212
await btn.dispatchEvent(clickEvent);
1313

14-
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><style>body { color: green; }</style>'), true);
14+
assert.equal(window.document.head.innerHTML.includes('<style>body { color: blue; }</style><!----><style>body { color: green; }</style>'), true);
1515
},
1616
};

0 commit comments

Comments
 (0)