Skip to content

Commit 94284b4

Browse files
committed
attempt to fix SSR issue with the newly added utilities & eslint triggers
1 parent 0d5c825 commit 94284b4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/bootstrap-vue-3/src/constants/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ declare var MozMutationObserver: any
33

44
export const HAS_WINDOW_SUPPORT = typeof window !== 'undefined'
55
export const HAS_DOCUMENT_SUPPORT = typeof document !== 'undefined'
6+
export const HAS_ELEMENT_SUPPORT = typeof Element !== 'undefined'
67
export const HAS_NAVIGATOR_SUPPORT = typeof navigator !== 'undefined'
78
export const HAS_PROMISE_SUPPORT = typeof Promise !== 'undefined'
89

packages/bootstrap-vue-3/src/utils/dom.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {Comment, Slot, VNode} from 'vue'
2-
import {DOCUMENT} from '../constants/env'
2+
import {DOCUMENT, HAS_ELEMENT_SUPPORT} from '../constants/env'
33
import {AnimationFrame} from '../types/safeTypes'
44
import {HAS_WINDOW_SUPPORT} from './env'
55
import {toString} from './stringUtils'
66

7-
const ELEMENT_PROTO = Element.prototype
7+
const ELEMENT_PROTO = HAS_ELEMENT_SUPPORT ? Element.prototype : undefined
88

99
// See: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
1010
/* istanbul ignore next */
1111
export const matchesEl =
12-
ELEMENT_PROTO.matches ||
13-
(ELEMENT_PROTO as any).msMatchesSelector ||
14-
ELEMENT_PROTO.webkitMatchesSelector
12+
ELEMENT_PROTO?.matches ||
13+
(ELEMENT_PROTO as any)?.msMatchesSelector ||
14+
ELEMENT_PROTO?.webkitMatchesSelector
1515

1616
/**
1717
* @param el
@@ -215,7 +215,7 @@ export const matches = (el: Element, selector: string) =>
215215
// See: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
216216
/* istanbul ignore next */
217217
export const closestEl =
218-
ELEMENT_PROTO.closest ||
218+
ELEMENT_PROTO?.closest ||
219219
function (this: Element, sel: string) {
220220
let el = this
221221
if (!el) return null

0 commit comments

Comments
 (0)