File tree 2 files changed +58
-6
lines changed
2 files changed +58
-6
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,20 @@ function isTabDisabled(node) {
19
19
return node . getAttribute ( 'aria-disabled' ) === 'true' ;
20
20
}
21
21
22
- const canUseActiveElement = ! ! (
23
- typeof window !== 'undefined' &&
24
- window . document &&
25
- window . document . activeElement
26
- ) ;
27
-
22
+ let canUseActiveElement ;
23
+ try {
24
+ canUseActiveElement = ! ! (
25
+ typeof window !== 'undefined' &&
26
+ window . document &&
27
+ window . document . activeElement
28
+ ) ;
29
+ } catch ( e ) {
30
+ // Work around for IE bug when accessing document.activeElement in an iframe
31
+ // Refer to the following resources:
32
+ // http://stackoverflow.com/a/10982960/369687
33
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12733599
34
+ canUseActiveElement = false ;
35
+ }
28
36
export default class UncontrolledTabs extends Component {
29
37
static defaultProps = {
30
38
className : 'react-tabs' ,
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @jest -environment node
3
+ */
4
+ /* eslint-env jest */
5
+ import React from 'react' ;
6
+ import Tab from '../Tab' ;
7
+ import TabList from '../TabList' ;
8
+ import TabPanel from '../TabPanel' ;
9
+ import Tabs from '../Tabs' ;
10
+ import { reset as resetIdCounter } from '../../helpers/uuid' ;
11
+
12
+ function createTabs ( props = { } ) {
13
+ return (
14
+ < Tabs { ...props } >
15
+ < TabList >
16
+ < Tab > Foo</ Tab >
17
+ < Tab > Bar</ Tab >
18
+ < Tab >
19
+ < a > Baz</ a >
20
+ </ Tab >
21
+ < Tab disabled > Qux</ Tab >
22
+ </ TabList >
23
+ < TabPanel > Hello Foo</ TabPanel >
24
+ < TabPanel > Hello Bar</ TabPanel >
25
+ < TabPanel > Hello Baz</ TabPanel >
26
+ < TabPanel > Hello Qux</ TabPanel >
27
+ </ Tabs >
28
+ ) ;
29
+ }
30
+
31
+ describe ( 'ServerSide <Tabs />' , ( ) => {
32
+ beforeEach ( ( ) => resetIdCounter ( ) ) ;
33
+
34
+ beforeAll ( ( ) => {
35
+ // eslint-disable-next-line no-console
36
+ console . error = error => {
37
+ throw new Error ( error ) ;
38
+ } ;
39
+ } ) ;
40
+
41
+ test ( 'does not crash in node environments' , ( ) => {
42
+ expect ( ( ) => createTabs ( ) ) . not . toThrow ( ) ;
43
+ } ) ;
44
+ } ) ;
You can’t perform that action at this time.
0 commit comments