You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at a (<anonymous>:8:17)
at <anonymous>:33:25
at Array.forEach (<anonymous>)
at a (<anonymous>:28:26)
at <anonymous>:33:25
at Array.forEach (<anonymous>)
at a (<anonymous>:28:26)
at <anonymous>:1:1
Your Example Website or App
示例在步骤中提供
Steps to Reproduce the Bug or Issue
调用 updateNode 方法,进入到 @antv/xflow/src/util/object.ts 中的 function apply(target: any, patchItem: any): any 方法;
单独测试 apply ,出现 **Uncaught SyntaxError: Unexpected token u in JSON at position 0**
functionapply(target: any,patchItem: any): any{/** * If the patch is anything other than an object, * the result will always be to replace * the entire target with the entire patch. */if(typeofpatchItem!=="object"||Array.isArray(patchItem)||!patchItem){returnJSON.parse(JSON.stringify(patchItem));//return new instance of variable}if(typeofpatchItem==="object"&&patchItem.toJSON!==undefined&&typeofpatchItem.toJSON==="function"){returnpatchItem.toJSON();}/** Also, it is not possible to * patch part of a target that is not an object, * such as to replace just some of the values in an array. */lettargetResult=target;if(typeoftarget!=="object"){//Target is empty/not an object, so basically becomes patch, minus any null valued sections (becomes {} + patch)targetResult={ ...patchItem};}Object.keys(patchItem).forEach((k)=>{if(!targetResult.hasOwnProperty(k))targetResult[k]=patchItem[k];//This ensure the key exists and TS can't throw a wobbly over an undefined keyif(patchItem[k]===null){deletetargetResult[k];}else{targetResult[k]=apply(targetResult[k],patchItem[k]);}});returntargetResult;}apply({},{data: undefined});
Describe the bug
使用 useGraphStore() 提供的 updateNode 方法更新节点数据,data 参数中含有 { value: undefined } 类似的属性值,出现错误;
报错信息如下:
Your Example Website or App
示例在步骤中提供
Steps to Reproduce the Bug or Issue
function apply(target: any, patchItem: any): any
方法;apply
,出现**Uncaught SyntaxError: Unexpected token u in JSON at position 0**
Expected behavior
方法中仅对
null
的情形进行了delete targetResult[k];
,忽略了undefined
的情形;期望:对
undefined
进行处理Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: