File tree 3 files changed +4
-13
lines changed
3 files changed +4
-13
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
- $ ,
3
2
isServer ,
4
3
detectOS ,
5
4
getEventListenerOptions ,
@@ -19,9 +18,9 @@ const lockedElements: HTMLElement[] = []
19
18
const eventListenerOptions = getEventListenerOptions ( { passive : false } )
20
19
21
20
const setOverflowHiddenPc = ( ) => {
22
- const $body = $ ( ' body' )
21
+ const $body = document . body
23
22
const bodyStyle = { ...$body . style }
24
- const scrollBarWidth = window . innerWidth - document . body . clientWidth
23
+ const scrollBarWidth = window . innerWidth - $ body. clientWidth
25
24
26
25
$body . style . overflow = 'hidden'
27
26
$body . style . boxSizing = 'border-box'
@@ -35,8 +34,8 @@ const setOverflowHiddenPc = () => {
35
34
}
36
35
37
36
const setOverflowHiddenMobile = ( ) => {
38
- const $html = $ ( 'html' )
39
- const $body = $ ( ' body' )
37
+ const $html = document . documentElement
38
+ const $body = document . body
40
39
const scrollTop = $html . scrollTop || $body . scrollTop
41
40
const htmlStyle = { ...$html . style }
42
41
const bodyStyle = { ...$body . style }
Original file line number Diff line number Diff line change 1
1
export const isServer = ( ) => typeof window === 'undefined'
2
2
3
- export const $ = ( selector : string ) => < HTMLElement > document . querySelector ( selector )
4
-
5
3
export interface DetectOSResult { ios : boolean , android : boolean }
6
4
export const detectOS = ( ua ?: string ) : DetectOSResult => {
7
5
ua = ua || navigator . userAgent
Original file line number Diff line number Diff line change 2
2
* @jest -environment jsdom-thirteen
3
3
*/
4
4
import {
5
- $ ,
6
5
isServer ,
7
6
detectOS ,
8
7
getEventListenerOptions ,
9
8
} from '@/utils'
10
9
11
10
describe ( 'utils' , ( ) => {
12
-
13
- it ( '$' , ( ) => {
14
- expect ( $ ( 'body' ) . tagName ) . toBe ( 'BODY' )
15
- } )
16
-
17
11
it ( `should detect server` , ( ) => {
18
12
expect ( isServer ( ) ) . toBe ( false )
19
13
} )
You can’t perform that action at this time.
0 commit comments