Permalink
Browse files
fix(tabs): Handle nodes with parentNode set to undefined instead of n…
- Loading branch information
|
@@ -12,8 +12,8 @@ |
|
|
"build:esm": "babel src/ --out-dir esm/ --ignore **/__tests__,**/__mocks__", |
|
|
"build:umd": "rollup -c", |
|
|
"build": "npm-run-all clean:* --parallel build:*", |
|
|
"format": "eslint src --fix", |
|
|
"lint": "eslint src", |
|
|
"format": "eslint src --fix --report-unused-disable-directives", |
|
|
"lint": "eslint src --report-unused-disable-directives", |
|
|
"precommit": "lint-staged", |
|
|
"prebump": "run-s lint test", |
|
|
"prepublish": "yarn run build", |
|
|
|
@@ -7,14 +7,18 @@ import { getPanelsCount, getTabsCount } from '../helpers/count'; |
|
|
import { deepMap } from '../helpers/childrenDeepMap'; |
|
|
import { isTabList, isTabPanel, isTab } from '../helpers/elementTypes'; |
|
|
|
|
|
function isNode(node) { |
|
|
return node && 'getAttribute' in node; |
|
|
} |
|
|
|
|
|
// Determine if a node from event.target is a Tab element |
|
|
function isTabNode(node) { |
|
|
return 'getAttribute' in node && node.getAttribute('role') === 'tab'; |
|
|
return isNode(node) && node.getAttribute('role') === 'tab'; |
|
|
} |
|
|
|
|
|
// Determine if a tab node is disabled |
|
|
function isTabDisabled(node) { |
|
|
return node.getAttribute('aria-disabled') === 'true'; |
|
|
return isNode(node) && node.getAttribute('aria-disabled') === 'true'; |
|
|
} |
|
|
|
|
|
let canUseActiveElement; |
|
@@ -298,7 +302,7 @@ export default class UncontrolledTabs extends Component { |
|
|
this.setSelected(index, e); |
|
|
return; |
|
|
} |
|
|
} while ((node = node.parentNode) !== null); |
|
|
} while ((node = node.parentNode) != null); |
|
|
}; |
|
|
|
|
|
/** |
|
|
|
|
@@ -1,5 +1,4 @@ |
|
|
/* eslint-env jest */ |
|
|
/* eslint-disable react/no-multi-comp */ |
|
|
import React from 'react'; |
|
|
import Enzyme, { shallow, mount } from 'enzyme'; |
|
|
import Adapter from 'enzyme-adapter-react-16'; |
|
|
0 comments on commit
83f8780