Skip to content

Commit f7a2664

Browse files
committed
fix(core): escape node labels (#1695)
* fix(core): escape node labels Signed-off-by: braks <[email protected]> * chore(changeset): add Signed-off-by: braks <[email protected]> --------- Signed-off-by: braks <[email protected]>
1 parent 4b8139d commit f7a2664

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.changeset/tame-cups-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Escape node labels and avoid rendering them as innerHTML

packages/core/src/components/Nodes/DefaultNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Component, FunctionalComponent } from 'vue'
2-
import { h } from 'vue'
2+
import { Fragment, h } from 'vue'
33
import Handle from '../Handle/Handle.vue'
44
import type { NodeProps } from '../../types'
55
import { Position } from '../../types'
@@ -17,7 +17,7 @@ const DefaultNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1717

1818
return [
1919
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
20-
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
20+
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
2121
h(Handle as Component, { type: 'source', position: sourcePosition, connectable, isValidConnection: isValidSourcePos }),
2222
]
2323
}

packages/core/src/components/Nodes/InputNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Component, FunctionalComponent } from 'vue'
2-
import { h } from 'vue'
2+
import { Fragment, h } from 'vue'
33
import Handle from '../Handle/Handle.vue'
44
import type { NodeProps } from '../../types'
55
import { Position } from '../../types'
@@ -14,7 +14,7 @@ const InputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1414
const label = data.label || _label
1515

1616
return [
17-
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
17+
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
1818
h(Handle as Component, { type: 'source', position: sourcePosition, connectable, isValidConnection: isValidSourcePos }),
1919
]
2020
}

packages/core/src/components/Nodes/OutputNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Component, FunctionalComponent } from 'vue'
2-
import { h } from 'vue'
2+
import { Fragment, h } from 'vue'
33
import Handle from '../Handle/Handle.vue'
44
import type { NodeProps } from '../../types'
55
import { Position } from '../../types'
@@ -15,7 +15,7 @@ const OutputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
1515

1616
return [
1717
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
18-
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
18+
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
1919
]
2020
}
2121

0 commit comments

Comments
 (0)