Existence guard containerProps.children (#257)

Prevents a `Cannot read property 'children' of undefined` error if using an element not yet defined, therefore allows the `Element is not defined` error to actually throw.
This commit is contained in:
Alex Rosario 2020-01-30 12:36:36 -05:00 committed by GitHub
parent 125869ce79
commit 0722b3c2c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,18 +24,22 @@ export default (props: {}) => {
);
const quit = () => {
for (let i = 0; i < containerProps.children[0].children.length; i++) {
containerProps.children[0].children[i].element.close();
if (containerProps.children && containerProps.children.length) {
for (let i = 0; i < containerProps.children[0].children.length; i++) {
containerProps.children[0].children[i].element.close();
}
}
disconnectDevtools();
};
const interval = setInterval(() => {
for (let i = 0; i < containerProps.children[0].children.length; i++) {
const closed = containerProps.children[0].children[i].element.getClosed();
if (!closed) {
element.runLoop();
return;
if (containerProps.children && containerProps.children.length) {
for (let i = 0; i < containerProps.children[0].children.length; i++) {
const closed = containerProps.children[0].children[i].element.getClosed();
if (!closed) {
element.runLoop();
return;
}
}
}
quit();