Skip to content

Commit

Permalink
fix(core): escape node labels (#1695)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
bcakmakoglu committed Nov 13, 2024
1 parent 4b8139d commit f7a2664
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-cups-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---

Escape node labels and avoid rendering them as innerHTML
4 changes: 2 additions & 2 deletions packages/core/src/components/Nodes/DefaultNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Component, FunctionalComponent } from 'vue'
import { h } from 'vue'
import { Fragment, h } from 'vue'
import Handle from '../Handle/Handle.vue'
import type { NodeProps } from '../../types'
import { Position } from '../../types'
Expand All @@ -17,7 +17,7 @@ const DefaultNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({

return [
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
h(Handle as Component, { type: 'source', position: sourcePosition, connectable, isValidConnection: isValidSourcePos }),
]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Nodes/InputNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Component, FunctionalComponent } from 'vue'
import { h } from 'vue'
import { Fragment, h } from 'vue'
import Handle from '../Handle/Handle.vue'
import type { NodeProps } from '../../types'
import { Position } from '../../types'
Expand All @@ -14,7 +14,7 @@ const InputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({
const label = data.label || _label

return [
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
h(Handle as Component, { type: 'source', position: sourcePosition, connectable, isValidConnection: isValidSourcePos }),
]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Nodes/OutputNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Component, FunctionalComponent } from 'vue'
import { h } from 'vue'
import { Fragment, h } from 'vue'
import Handle from '../Handle/Handle.vue'
import type { NodeProps } from '../../types'
import { Position } from '../../types'
Expand All @@ -15,7 +15,7 @@ const OutputNode: FunctionalComponent<NodeProps<{ label: any }>> = function ({

return [
h(Handle as Component, { type: 'target', position: targetPosition, connectable, isValidConnection: isValidTargetPos }),
typeof label !== 'string' && label ? h(label) : h('div', { innerHTML: label }),
typeof label !== 'string' && label ? h(label) : h(Fragment, [label]),
]
}

Expand Down

0 comments on commit f7a2664

Please sign in to comment.