Search in sources :

Example 86 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class TemplateElementStateProviderTest method templateStaticStyleGetUsingDashSeparated.

@Test
public void templateStaticStyleGetUsingDashSeparated() {
    Element element = createElement("<div style='font-size:14px'></div>");
    Assert.assertEquals("14px", element.getStyle().get("font-size"));
    Assert.assertEquals("14px", element.getStyle().get("fontSize"));
    Assert.assertNull(element.getStyle().get("fontsize"));
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 87 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class TemplateElementStateProviderTest method testRemoveOverrideChildByInstance.

@Test
public void testRemoveOverrideChildByInstance() {
    Element child = new Element("a");
    Element parent = createElement("<div></div>");
    parent.appendChild(child);
    parent.removeChild(child);
    Assert.assertEquals(0, parent.getChildCount());
    Assert.assertFalse(parent.getChildren().findFirst().isPresent());
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 88 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class TemplateElementStateProviderTest method setAttribute_boundAttribute_throwException.

@Test(expected = IllegalArgumentException.class)
public void setAttribute_boundAttribute_throwException() {
    Element element = createElement("<div [attr.attr]='value'></div>");
    element.setAttribute("attr", "foo");
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 89 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class TemplateElementStateProviderTest method removeRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue.

@Test
public void removeRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue() {
    TemplateNode node = TemplateParser.parse("<div [foo]='bar'></div>", new NullTemplateResolver());
    Element element = createElement(node);
    element.setProperty("prop", "foo");
    element.removeProperty("prop");
    Assert.assertFalse(element.hasProperty("prop"));
    Set<String> props = element.getPropertyNames().collect(Collectors.toSet());
    Assert.assertEquals(1, props.size());
    Assert.assertTrue(props.contains("foo"));
}
Also used : TemplateNode(com.vaadin.flow.template.angular.TemplateNode) Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 90 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class TemplateElementStateProviderTest method testTextNode.

@Test
public void testTextNode() {
    TextTemplateBuilder builder = new TextTemplateBuilder(new StaticBindingValueProvider("Hello"));
    Element element = createElement(builder);
    Assert.assertTrue(element.isTextNode());
    Assert.assertEquals("Hello", element.getTextRecursively());
}
Also used : TextTemplateBuilder(com.vaadin.flow.template.angular.TextTemplateBuilder) Element(com.vaadin.flow.dom.Element) StaticBindingValueProvider(com.vaadin.flow.template.angular.StaticBindingValueProvider) Test(org.junit.Test)

Aggregations

Element (com.vaadin.flow.dom.Element)377 Test (org.junit.Test)322 UI (com.vaadin.flow.component.UI)42 StateNode (com.vaadin.flow.internal.StateNode)32 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)29 Style (com.vaadin.flow.dom.Style)25 StreamResource (com.vaadin.flow.server.StreamResource)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 ArrayList (java.util.ArrayList)14 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)13 JsonObject (elemental.json.JsonObject)12 WeakReference (java.lang.ref.WeakReference)12 URI (java.net.URI)11 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)10 Registration (com.vaadin.flow.shared.Registration)10 JsonValue (elemental.json.JsonValue)10 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)8 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)8