8000 perf: only set attribute if it doesn't exist · danielroe/vue-bind-once@006cf8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 006cf8e

Browse files
committed
perf: only set attribute if it doesn't exist
1 parent e6f0107 commit 006cf8e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export const BindOnceDirective: Directive = {
55
created(el, binding) {
66
for (const key in binding.value) {
77
const k = kebabCase(key)
8-
el.setAttribute(k, el.getAttribute(k) || binding.value[key])
8+
if (!el.hasAttribute(k)) {
9+
el.setAttribute(k, binding.value[key])
10+
}
911
}
1012
},
1113
getSSRProps(binding) {

0 commit comments

Comments
 (0)
0