ExecuteJavaScriptProcessor { protected boolean isBound(StateNode node) { boolean isNodeBound = node.getDomNode() != null && !SimpleElementBindingStrategy.needsRebind(node); if (!isNodeBound || node.getParent() == null) { return isNodeBound; } return isBound(node.getParent()); } ExecuteJavaScriptProcessor(Registry registry); void execute(JsonArray invocations);  }
@Test public void isBound_noElement_notBound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); Assert.assertFalse(processor.isBound(node)); }
@Test public void isBound_hasElementHasNoFeature_bound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); JsElement element = new JsElement() { }; node.setDomNode(element); Assert.assertTrue(processor.isBound(node)); }
@Test public void isBound_hasElementHasFeatureAndBound_bound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); JsElement element = new JsElement() { }; node.setDomNode(element); node.getMap(NodeFeatures.ELEMENT_DATA) .getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) .setValue(true); Assert.assertTrue(processor.isBound(node)); }
@Test public void isBound_hasElementHasFeatureAndNotBound_notBound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); JsElement element = new JsElement() { }; node.setDomNode(element); node.getMap(NodeFeatures.ELEMENT_DATA) .getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) .setValue(false); Assert.assertFalse(processor.isBound(node)); }
@Test public void isBound_hasElementHasNoFeatureAndBoundParent_bound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); StateNode parent = new StateNode(43, registry.getStateTree()); node.setParent(parent); JsElement element = new JsElement() { }; node.setDomNode(element); parent.setDomNode(element); Assert.assertTrue(processor.isBound(node)); }
@Test public void isBound_hasElementHasNoFeatureAndUnboundParent_notBound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); StateNode parent = new StateNode(43, registry.getStateTree()); node.setParent(parent); JsElement element = new JsElement() { }; node.setDomNode(element); Assert.assertFalse(processor.isBound(node)); }
@Test public void isBound_hasElementHasFeatureAndBoundAndUnboundParent_notBound() { TestJsProcessor processor = new TestJsProcessor(); Registry registry = processor.getRegistry(); StateNode node = new StateNode(37, registry.getStateTree()); node.getMap(NodeFeatures.ELEMENT_DATA) .getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY) .setValue(true); StateNode parent = new StateNode(43, registry.getStateTree()); node.setParent(parent); JsElement element = new JsElement() { }; node.setDomNode(element); Assert.assertFalse(processor.isBound(node)); }