Don't crash on iOS if there is only a single SemanticsNode (flutter/engine#4128)

* Don't crash if there is only a single SemanticsNode

Previously, the code assumed that the root SemanticsNode will allways have a child. This is not true as can be seen in the hello_world example app, which would crash when a11y is turned on.

* review comment
This commit is contained in:
Michael Goderbauer
2017-09-20 14:17:50 -07:00
committed by GitHub
parent 41e2e6dc9f
commit dca7480bd3

View File

@@ -206,11 +206,12 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) {
#pragma mark - UIAccessibilityElement protocol
- (id)accessibilityContainer {
if ([self hasChildren]) {
if ([self hasChildren] || _uid == kRootNodeId) {
if (_container == nil)
_container = [[SemanticsObjectContainer alloc] initWithSemanticsObject:self bridge:_bridge];
return _container;
}
NSAssert(_parent != nil, @"Illegal access to non-existent parent of root semantics node");
return [_parent accessibilityContainer];
}