containerClildListOnChange optimised

This commit is contained in:
NikolaBorislavovHristov 2019-01-21 15:37:13 +02:00
parent 4cb7c20b12
commit a06423f0ec

View file

@ -29,16 +29,7 @@ class FocusableProvider extends Component {
}
containerClildListOnChange = () => {
for (let i = this.childElementRef.current.parentElement.children.length - 1; i >= 0; i--) {
const child = this.childElementRef.current.parentElement.children[i];
const tagName = child.tagName.toLowerCase();
if (tagName !== 'script' && tagName !== 'style') {
this.setState({
focusable: this.childElementRef.current === child
});
break;
}
}
this.setState({ focusable: this.childElementRef.current.nextElementSibling === null });
}
render() {