Skip to content

Commit 0890bbd

Browse files
committed
refactor(compiler): use VaporFragment from vue
1 parent 31b074b commit 0890bbd

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.changeset/strong-dryers-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'unplugin-vue-jsx-vapor': patch
3+
---
4+
5+
use VaporFragment from vue

packages/unplugin/src/core/helper/code.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { createIf, effectScope, insert, remove, renderEffect } from 'vue'
1+
import {
2+
VaporFragment,
3+
effectScope,
4+
insert,
5+
isFragment,
6+
remove,
7+
renderEffect,
8+
} from 'vue'
29

3-
const VaporFragment = createIf(() => {}).__proto__.__proto__.constructor
410
function createFragment(nodes) {
511
const frag = new VaporFragment(nodes)
612
frag.anchor = document.createTextNode('')
@@ -10,7 +16,7 @@ function createFragment(nodes) {
1016
function normalizeValue(value) {
1117
return value == null || typeof value === 'boolean'
1218
? document.createTextNode('')
13-
: value instanceof Node || value instanceof VaporFragment
19+
: value instanceof Node || isFragment(value)
1420
? value
1521
: Array.isArray(value)
1622
? createFragment(value.map(normalizeValue))
@@ -20,15 +26,15 @@ function normalizeValue(value) {
2026
function resolveValue(current, value) {
2127
const node = normalizeValue(value)
2228
if (current) {
23-
if (current instanceof VaporFragment) {
29+
if (isFragment(current)) {
2430
const { anchor } = current
2531
if (anchor.parentNode) {
2632
remove(current.nodes, anchor.parentNode)
2733
insert(node, anchor.parentNode, anchor)
2834
anchor.remove()
2935
}
3036
} else if (current.nodeType) {
31-
if (node instanceof VaporFragment && current.parentNode) {
37+
if (isFragment(node) && current.parentNode) {
3238
insert(node, current.parentNode, current)
3339
current.remove()
3440
} else if (current.nodeType === 3 && node.nodeType === 3) {

0 commit comments

Comments
 (0)