Skip to content

Commit

Permalink
* [android] fix invaild add dom operation
Browse files Browse the repository at this point in the history
  • Loading branch information
sospartan committed Aug 17, 2016
1 parent 288a5fa commit 7b1ad97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ void addDom(JSONObject dom, final String parentRef, final int index) {

//Create component in dom thread
final WXComponent component = mWXRenderManager.createComponentOnDomThread(mInstanceId, domObject, parentRef, index);
if(component == null){
//stop redner, some fatal happened.
return;
}
AddDomInfo addDomInfo = new AddDomInfo();
addDomInfo.component = component;
mAddDom.put(domObject.getRef(), addDomInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public void addComponent(String instanceId, WXDomObject dom, String parentRef, i
statement.addComponent(dom, parentRef, index);
}

public WXComponent createComponentOnDomThread(String instanceId, WXDomObject dom, String parentRef, int index) {
public @Nullable WXComponent createComponentOnDomThread(String instanceId, WXDomObject dom, String parentRef, int index) {
WXRenderStatement statement = mRegistries.get(instanceId);
if (statement == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ void addComponent(WXDomObject dom, String parentRef, int index) {
parent.addChild(component, index);
}

WXComponent createComponentOnDomThread(WXDomObject dom, String parentRef, int index) {
@Nullable WXComponent createComponentOnDomThread(WXDomObject dom, String parentRef, int index) {
WXComponent comp = mRegistry.get(parentRef);
if(comp == null || !(comp instanceof WXVContainer)){
return null;
}
return generateComponentTree(dom, (WXVContainer) mRegistry.get(parentRef));
}

Expand Down

0 comments on commit 7b1ad97

Please sign in to comment.