fix: disable inherting attrs on nodes/edges to avoid warnings

* disable context warnings for non-dev environments

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-16 16:01:44 +01:00
parent 63f710e422
commit a58d952e9f
12 changed files with 45 additions and 12 deletions
+5
View File
@@ -58,6 +58,11 @@ const path = computed(() => {
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId)) const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" /> <path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" />
<EdgeText <EdgeText
+5
View File
@@ -61,6 +61,11 @@ const path = computed(() => {
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId)) const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" /> <path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" />
<EdgeText <EdgeText
+5
View File
@@ -63,6 +63,11 @@ const path = computed(() => {
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId)) const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" /> <path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
<EdgeText <EdgeText
+5
View File
@@ -16,6 +16,11 @@ const props = withDefaults(defineProps<DefaultNodeProps>(), {
sourcePosition: Position.Bottom, sourcePosition: Position.Bottom,
}) })
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<Handle type="target" :position="props.targetPosition" :is-connectable="props.connectable" /> <Handle type="target" :position="props.targetPosition" :is-connectable="props.connectable" />
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" /> <component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
+5
View File
@@ -14,6 +14,11 @@ const props = withDefaults(defineProps<InputNodeProps>(), {
sourcePosition: Position.Bottom, sourcePosition: Position.Bottom,
}) })
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" /> <component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
<span v-else v-html="props.data?.label"></span> <span v-else v-html="props.data?.label"></span>
-1
View File
@@ -129,7 +129,6 @@ onMounted(() => {
}) })
}) })
</script> </script>
<template> <template>
<DraggableCore <DraggableCore
cancel=".nodrag" cancel=".nodrag"
+5
View File
@@ -14,6 +14,11 @@ const props = withDefaults(defineProps<OutputNodeProps>(), {
targetPosition: Position.Top, targetPosition: Position.Top,
}) })
</script> </script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template> <template>
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" /> <component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
<span v-else v-html="props.data?.label"></span> <span v-else v-html="props.data?.label"></span>
@@ -30,6 +30,8 @@ const onMouseLeave = () => {
store.unsetNodesSelection() store.unsetNodesSelection()
} }
const userSelectionRect = computed(() => store.userSelectionRect)
useEventListener(el, 'mousedown', onMouseDown) useEventListener(el, 'mousedown', onMouseDown)
useEventListener(el, 'mousemove', onMouseMove) useEventListener(el, 'mousemove', onMouseMove)
useEventListener(el, 'click', onMouseUp) useEventListener(el, 'click', onMouseUp)
@@ -39,11 +41,11 @@ useEventListener(el, 'mouseleave', onMouseLeave)
<template> <template>
<div ref="user-selection" class="vue-flow__selectionpane"> <div ref="user-selection" class="vue-flow__selectionpane">
<SelectionRect <SelectionRect
v-if="store.userSelectionRect.draw" v-if="userSelectionRect.draw"
:width="store.userSelectionRect.width" :width="userSelectionRect.width"
:height="store.userSelectionRect.height" :height="userSelectionRect.height"
:x="store.userSelectionRect.x" :x="userSelectionRect.x"
:y="store.userSelectionRect.y" :y="userSelectionRect.y"
/> />
</div> </div>
</template> </template>
+1 -1
View File
@@ -1,4 +1,4 @@
import { XYPosition } from '../../types' import { XYPosition } from '~/types'
export function getMousePosition(event: MouseEvent): XYPosition | void { export function getMousePosition(event: MouseEvent): XYPosition | void {
const flowNode = (event.target as Element).closest('.vue-flow') const flowNode = (event.target as Element).closest('.vue-flow')
+1 -1
View File
@@ -66,7 +66,7 @@ export const createHooks = (): FlowHooks & { bind: (emit: EmitFunc) => FlowHooks
export default (emit?: EmitFunc) => { export default (emit?: EmitFunc) => {
let hooks = inject(Hooks)! let hooks = inject(Hooks)!
if (!hooks) { if (!hooks) {
console.warn('hooks context not found; creating default hooks') if (import.meta.env.DEV) console.warn('hooks context not found; creating default hooks')
if (!emit) console.error('no emit function found for hook context.') if (!emit) console.error('no emit function found for hook context.')
else { else {
hooks = createHooks().bind(emit) hooks = createHooks().bind(emit)
+1 -1
View File
@@ -5,7 +5,7 @@ import { Store } from '~/context'
export default (options?: Partial<FlowOptions>) => { export default (options?: Partial<FlowOptions>) => {
let store = inject(Store)! let store = inject(Store)!
if (!store) { if (!store) {
console.warn('store context not found; creating default store') if (import.meta.env.DEV) console.warn('store context not found; creating default store')
store = useFlowStore({ store = useFlowStore({
...initialState(), ...initialState(),
...options, ...options,
+5 -3
View File
@@ -1,4 +1,6 @@
export default (): Window & typeof globalThis & { chrome?: any } => { type UseWindow = Window & typeof globalThis & { chrome?: any }
if (typeof window !== 'undefined') return window
else return {} as any export default (): UseWindow => {
if (typeof window !== 'undefined') return window as UseWindow
else return { chrome: false } as UseWindow
} }