Description
Steps to Reproduce
https://zkfiddle.org/sample/bgkjaq/5-Apply-null-host
Click do1
Click do2
Current Result
Caused by: java.lang.IllegalStateException: The insertion [<Apply>] of the shadow [<[email protected] (<Idspace cXlS6>)>] cannot be orphanCaused by: java.lang.IllegalStateException: The insertion [<Apply>] of the shadow [<[email protected] (<Idspace cXlS6>)>] cannot be orphan at org.zkoss.zk.ui.HtmlShadowElement.getIndex(HtmlShadowElement.java:1161) at org.zkoss.zk.ui.HtmlShadowElement.inRange(HtmlShadowElement.java:1196) at org.zkoss.zk.ui.HtmlShadowElement.adjustInsertionForRemove(HtmlShadowElement.java:990) at org.zkoss.zk.ui.HtmlShadowElement.beforeHostChildRemoved(HtmlShadowElement.java:744) at org.zkoss.zk.ui.HtmlShadowElement.beforeHostChildRemoved(HtmlShadowElement.java:798) at org.zkoss.zk.ui.AbstractComponent.triggerBeforeHostChildRemoved(AbstractComponent.java:4071) at org.zkoss.zk.ui.AbstractComponent.removeChild(AbstractComponent.java:1561) at org.zkoss.zk.ui.AbstractComponent.setParent(AbstractComponent.java:1230) at org.zkoss.zk.ui.AbstractComponent.detach(AbstractComponent.java:1966) at org.zkoss.zk.ui.HtmlShadowElement.clearChildren(HtmlShadowElement.java:1313) at org.zkoss.zk.ui.HtmlShadowElement.recreate(HtmlShadowElement.java:1299) at org.zkoss.zuti.zul.TemplateBasedShadowElement$1.onEvent(TemplateBasedShadowElement.java:156) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3191) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3161) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3103) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1884) ... 22 more
Expected Result
no error
Debug Information
Seem to be caused by the "Clients" class being resolved on shadow elements by getShadowVariable.
It looks like the <sub2/> component (actually an include created by the <?component ... ?> processing instruction being merged an removed due to not having dynamic bindings causes it to still be in the list of shadow roots, but no longer bound?
Workaround
dynamicValue="true" on templateUri components which do not have dynamic variables assigned.
<sub2 dynamicValue="true"/>