File tree 1 file changed +12
-2
lines changed
packages/devui-vue/devui/shared/utils
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ export function isComponent(target: any): target is ComponentPublicInstance {
9
9
return ! ! ( target ?. $el ) ;
10
10
}
11
11
12
+ /**
13
+ * 兼容火狐浏览器判断是否为元素节点
14
+ * @param {any } element
15
+ * @returns {boolean }
16
+ */
17
+ function judgeFireIsElement ( element : Element | ComponentPublicInstance | null ) {
18
+ const str = Object . prototype . toString . call ( element ) ;
19
+ return str . includes ( 'object' ) && str . includes ( 'HTML' ) && str . includes ( 'Element' ) ;
20
+ }
21
+
12
22
/**
13
23
* 提取 Vue Intance 中的元素,如果本身就是元素,直接返回。
14
24
* @param {any } element
@@ -17,13 +27,13 @@ export function isComponent(target: any): target is ComponentPublicInstance {
17
27
export function getElement (
18
28
element : Element | ComponentPublicInstance | null
19
29
) : Element | null {
20
- if ( element instanceof Element ) {
30
+ if ( element instanceof Element || judgeFireIsElement ( element ) ) {
21
31
return element ;
22
32
}
23
33
if (
24
34
element &&
25
35
typeof element === 'object' &&
26
- element . $el instanceof Element
36
+ ( element . $el instanceof Element || judgeFireIsElement ( element . $el ) )
27
37
) {
28
38
return element . $el ;
29
39
}
You can’t perform that action at this time.
0 commit comments