File tree Expand file tree Collapse file tree 8 files changed +183
-22
lines changed Expand file tree Collapse file tree 8 files changed +183
-22
lines changed Original file line number Diff line number Diff line change 11* .swp
2+ node_modules /
3+ /test-results /
4+ /playwright-report /
5+ /playwright /.cache /
Original file line number Diff line number Diff line change 11# scrollparent.js
22
3+ [ ![ NPM version] [ npm-image ]] [ npm-url ]
4+ [ ![ Size] [ size-image ]] [ size-url ]
5+ [ ![ Download count] [ downloads-image ]] [ downloads-url ]
6+
37> A function to get the scrolling parent of an html element.
48
59## Install
@@ -45,3 +49,10 @@ you should use a `document.scrollingElement` polyfill such as
4549## License
4650
4751MIT
52+
53+ [ npm-image ] : https://img.shields.io/npm/v/scrollparent.svg?style=flat-square
54+ [ npm-url ] : https://npmjs.org/package/scrollparent
55+ [ downloads-image ] : http://img.shields.io/npm/dm/scrollparent.js.svg?style=flat-square
56+ [ downloads-url ] : https://npmjs.org/package/scrollparent.js
57+ [ size-image ] : https://badge-size.herokuapp.com/olahol/scrollparent.js/master/scrollparent.js?style=flat-square
58+ [ size-url ] : https://github.com/olahol/scrollparent.js/blob/master/react-tagsinput.js
Original file line number Diff line number Diff line change 1818 "bugs" : {
1919 "url" : " https://github.com/olahol/scrollparent.js/issues"
2020 },
21- "homepage" : " https://github.com/olahol/scrollparent.js#readme"
21+ "homepage" : " https://github.com/olahol/scrollparent.js#readme" ,
22+ "devDependencies" : {
23+ "@playwright/test" : " ^1.27.1"
24+ },
25+ "scripts" : {
26+ "test" : " playwright test"
27+ },
28+ "files" : []
2229}
Original file line number Diff line number Diff line change 1+ const { devices } = require ( '@playwright/test' ) ;
2+
3+ const config = {
4+ testDir : './test' ,
5+ timeout : 30 * 1000 ,
6+ expect : {
7+ timeout : 5000
8+ } ,
9+ workers : 1 ,
10+ reporter : 'html' ,
11+ projects : [
12+ {
13+ name : 'chromium' ,
14+ use : {
15+ ...devices [ 'Desktop Chrome' ] ,
16+ } ,
17+ } ,
18+
19+ {
20+ name : 'firefox' ,
21+ use : {
22+ ...devices [ 'Desktop Firefox' ] ,
23+ } ,
24+ } ,
25+
26+ {
27+ name : 'webkit' ,
28+ use : {
29+ ...devices [ 'Desktop Safari' ] ,
30+ } ,
31+ } ,
32+
33+ {
34+ name : 'mobile_chrome' ,
35+ use : {
36+ ...devices [ 'Pixel 5' ] ,
37+ } ,
38+ } ,
39+
40+ {
41+ name : 'mobile_safari' ,
42+ use : {
43+ ...devices [ 'iPhone 12' ] ,
44+ } ,
45+ } ,
46+ ] ,
47+ } ;
48+
49+ module . exports = config ;
Original file line number Diff line number Diff line change 2424 } ;
2525
2626 var scroll = function ( node ) {
27- return regex . test ( overflow ( node ) ) ;
27+ return regex . test ( overflow ( node ) ) ;
2828 } ;
2929
3030 var scrollParent = function ( node ) {
Original file line number Diff line number Diff line change 1+ const { resolve } = require ( 'path' ) ;
2+ const { test, expect } = require ( '@playwright/test' ) ;
3+
4+ test ( 'test scrollparent behaviour' , async ( { page } ) => {
5+ const testFile = resolve ( __dirname , 'test.html' ) ;
6+
7+ page . on ( 'console' , msg => console . log ( msg . text ( ) ) ) ;
8+
9+ await page . goto ( `file://${ testFile } ` ) ;
10+
11+ await expect ( page ) . toHaveTitle ( 'scrollparent.js test page' ) ;
12+
13+ await page . evaluate ( ( ) => {
14+ var top = document . scrollingElement || document . documentElement ;
15+
16+ function equal ( a , b , msg ) {
17+ if ( a !== b ) {
18+ throw new Error ( msg || "Page Error" ) ;
19+ }
20+ }
21+
22+ function byId ( id ) {
23+ return document . getElementById ( id ) ;
24+ }
25+
26+ equal ( Scrollparent ( byId ( "test1" ) ) . className , "scroll" ) ;
27+
28+ equal ( Scrollparent ( byId ( "test2" ) ) , top ) ;
29+ equal ( Scrollparent ( byId ( "test3" ) ) , top ) ;
30+
31+ equal ( Scrollparent ( byId ( "test4" ) ) . className , "scroll-y" ) ;
32+ equal ( Scrollparent ( byId ( "test5" ) ) . className , "scroll-x" ) ;
33+ } ) ;
34+ } ) ;
Original file line number Diff line number Diff line change 22< html >
33
44< head >
5- < title > </ title >
5+ < title > scrollparent.js test page </ title >
66 < meta charset ="utf-8 ">
77 < style >
88 .scroll {
114114 </ div >
115115</ div >
116116
117- < script src ="scrollparent.js "> </ script >
118- < script >
119- var equal = function ( a , b ) {
120- console . log ( ( a === b ? "ok" : "not ok" ) + " " + ( ++ assertion ) ) ;
121- }
122-
123- var assertion = 0 ;
124-
125- console . log ( "TAP version 13" ) ;
126- console . log ( "1..5" ) ;
127-
128- equal ( Scrollparent ( document . getElementById ( "test1" ) ) . className , "scroll" ) ;
129-
130- equal ( Scrollparent ( document . getElementById ( "test2" ) ) , document . scrollingElement || document . documentElement ) ;
131- equal ( Scrollparent ( document . getElementById ( "test3" ) ) , document . scrollingElement || document . documentElement ) ;
132-
133- equal ( Scrollparent ( document . getElementById ( "test4" ) ) . className , "scroll-y" ) ;
134- equal ( Scrollparent ( document . getElementById ( "test5" ) ) . className , "scroll-x" ) ;
135- </ script >
117+ < script src ="../scrollparent.js "> </ script >
136118</ body >
137119</ html >
You can’t perform that action at this time.
0 commit comments