@Test public void testRemoveDom() throws Exception { createBody(); JSONObject obj; obj = new JSONObject(); obj.put("type","div"); obj.put("ref","100"); stmt.addDom(obj,WXDomObject.ROOT,0); obj = new JSONObject(); obj.put("type","div"); obj.put("ref","101"); stmt.addDom(obj,WXDomObject.ROOT,0); stmt.removeDom("101"); stmt.batch(); }
void removeDom(final String ref) { if (mDestroy) { return; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId); WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(new WXDomObject.Consumer() { @Override public void accept(WXDomObject dom) { mRegistry.remove(dom.getRef()); } }); parent.remove(domObject); mRegistry.remove(ref); mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.removeComponent(mInstanceId, ref); } @Override public String toString() { return "removeDom"; } }); mDirty = true; if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } }
WXDomStatement { void removeDom(final String ref) { if (mDestroy) { return; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId); WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(new WXDomObject.Consumer() { @Override public void accept(WXDomObject dom) { mRegistry.remove(dom.getRef()); } }); parent.remove(domObject); mRegistry.remove(ref); mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.removeComponent(mInstanceId, ref); } @Override public String toString() { return "removeDom"; } }); mDirty = true; if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } } }
WXDomStatement { void removeDom(final String ref) { if (mDestroy) { return; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId); WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(new WXDomObject.Consumer() { @Override public void accept(WXDomObject dom) { mRegistry.remove(dom.getRef()); } }); parent.remove(domObject); mRegistry.remove(ref); mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.removeComponent(mInstanceId, ref); } @Override public String toString() { return "removeDom"; } }); mDirty = true; if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } } WXDomStatement(String instanceId, WXRenderManager renderManager); }
WXDomStatement { void removeDom(final String ref) { if (mDestroy) { return; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId); WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(new WXDomObject.Consumer() { @Override public void accept(WXDomObject dom) { mRegistry.remove(dom.getRef()); } }); parent.remove(domObject); mRegistry.remove(ref); mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.removeComponent(mInstanceId, ref); } @Override public String toString() { return "removeDom"; } }); mDirty = true; if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } } WXDomStatement(String instanceId, WXRenderManager renderManager); void destroy(); void getComponentSize(final String ref, final JSCallback callback); }
WXDomStatement { void removeDom(final String ref) { if (mDestroy) { return; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId); WXDomObject domObject = mRegistry.get(ref); if (domObject == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } WXDomObject parent = domObject.parent; if (parent == null) { if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT); } return; } domObject.traverseTree(new WXDomObject.Consumer() { @Override public void accept(WXDomObject dom) { mRegistry.remove(dom.getRef()); } }); parent.remove(domObject); mRegistry.remove(ref); mNormalTasks.add(new IWXRenderTask() { @Override public void execute() { mWXRenderManager.removeComponent(mInstanceId, ref); } @Override public String toString() { return "removeDom"; } }); mDirty = true; if (instance != null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); } } WXDomStatement(String instanceId, WXRenderManager renderManager); void destroy(); void getComponentSize(final String ref, final JSCallback callback);  }