Skip to content

Commit

Permalink
refactor(block): do not convert unless uncached
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Feb 15, 2022
1 parent 089dd1e commit 7647b35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -122,7 +122,7 @@
"typescript": "^4.5.5",
"unbuild": "^0.6.9",
"virtual-dom": "^2.1.1",
"vite": "^2.8.2",
"vite": "^2.8.3",
"vite-plugin-legacy": "^2.1.0",
"vitest": "^0.2.8",
"zx": "^4.3.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/block/block.ts
Expand Up @@ -5,12 +5,11 @@ import { fromDomNodeToVNode, fromStringToDomNode } from '../shared/convert';
const cache = new Map<string, VEntity>();

export const block = (html: string): VEntity => {
const el = fromStringToDomNode(html);
const vnode = fromDomNodeToVNode(el)!;

if (cache.has(html)) {
return cache.get(html)!;
} else {
const el = fromStringToDomNode(html);
const vnode = fromDomNodeToVNode(el)!;
const blockEntity = entity(
{
get el() {
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7647b35

Please sign in to comment.