Skip to content

Commit

Permalink
Resolve conflicts, add swipe, add @doc
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Oct 13, 2021
1 parent a9baa30 commit dd315ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/src/dom/selector-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* --------------------------------------------------------------------------
*/

import { isDisabled, isVisible } from '../util/index'
import { getDocument, isDisabled, isVisible } from '../util/index'

/**
* Constants
Expand Down
6 changes: 6 additions & 0 deletions js/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,16 @@ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed
return list[Math.max(0, Math.min(index, listLength - 1))]
}

/**
* @return {window|{}} The proper element
*/
const getWindow = () => {
return typeof window === 'undefined' ? {} : window
}

/**
* @return {document|{}} The proper element
*/
const getDocument = () => {
return typeof document === 'undefined' ? {} : document
}
Expand Down
6 changes: 3 additions & 3 deletions js/src/util/swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import EventHandler from '../dom/event-handler'
import { execute, typeCheckConfig } from './index'
import { execute, getDocument, getWindow, typeCheckConfig } from './index'

/**
* Constants
Expand Down Expand Up @@ -50,7 +50,7 @@ class Swipe {

this._config = this._getConfig(config)
this._deltaX = 0
this._supportPointerEvents = Boolean(window.PointerEvent)
this._supportPointerEvents = Boolean(getWindow().PointerEvent)
this._initEvents()
}

Expand Down Expand Up @@ -133,7 +133,7 @@ class Swipe {

// Static
static isSupported() {
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
return 'ontouchstart' in getDocument().documentElement || navigator.maxTouchPoints > 0
}
}

Expand Down

0 comments on commit dd315ad

Please sign in to comment.