Skip to content

Commit b262757

Browse files
zamhownkkxxkk2019
authored andcommitted
fix: error in tooltip parentElement
1 parent b154216 commit b262757

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/vchart/src/util/spec.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,25 @@ export function cloneDeepSpec(spec: any) {
9292
}
9393

9494
export function isDataView(obj: any): obj is DataView {
95-
const dataViewKeys: (keyof DataView)[] = ['dataSet', 'latestData', 'rawData', 'parserData', 'isDataView', 'history'];
96-
const keys = Object.keys(obj);
97-
return obj instanceof DataView || dataViewKeys.every(key => keys.includes(key));
95+
return obj instanceof DataView;
9896
}
9997

10098
export function isHTMLElement(obj: any): obj is Element {
101-
return obj instanceof Element;
99+
try {
100+
return obj instanceof Element;
101+
} catch {
102+
// 跨端 plan B
103+
const htmlElementKeys: (keyof Element)[] = [
104+
'children',
105+
'innerHTML',
106+
'classList',
107+
'setAttribute',
108+
'tagName',
109+
'getBoundingClientRect'
110+
];
111+
const keys = Object.keys(obj);
112+
return htmlElementKeys.every(key => keys.includes(key));
113+
}
102114
}
103115

104116
export function convertBackgroundSpec(

0 commit comments

Comments
 (0)