Skip to content

Commit

Permalink
perf: convert empty text nodes to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shirotech committed Aug 21, 2020
1 parent 82dc26a commit 6df7989
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function space() {
}

export function empty() {
return text('');
return document.createComment('');
}

export function listen(node: EventTarget, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | EventListenerOptions) {
Expand Down
6 changes: 3 additions & 3 deletions test/runtime/samples/raw-mustache-inside-head/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ export default {
const btn = target.querySelector("button");
const clickEvent = new window.MouseEvent("click");

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

await btn.dispatchEvent(clickEvent);

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

await btn.dispatchEvent(clickEvent);

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

0 comments on commit 6df7989

Please sign in to comment.