Search in sources :

Example 61 with Element

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

the class ElementTest method callFunctionBeforeReAttach.

@Test
public void callFunctionBeforeReAttach() {
    UI ui = new UI();
    Element element = ElementFactory.createDiv();
    ui.getElement().appendChild(element);
    element.callFunction("noArgsMethod");
    Element div = ElementFactory.createDiv();
    ui.getElement().appendChild(div);
    div.appendChild(element);
    ui.getInternals().getStateTree().runExecutionsBeforeClientResponse();
    assertPendingJs(ui, "$0.noArgsMethod()", element);
}
Also used : UI(com.vaadin.flow.component.UI) Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 62 with Element

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

the class ElementTest method attributesNamesAfterRemoved.

@Test
public void attributesNamesAfterRemoved() {
    Element e = ElementFactory.createDiv();
    e.setAttribute("foo", "bar");
    e.setAttribute("bar", "baz");
    e.removeAttribute("foo");
    Assert.assertArrayEquals(new String[] { "bar" }, e.getAttributeNames().toArray());
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 63 with Element

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

the class ElementTest method setStyleAttributeTrailingSemicolon.

@Test
public void setStyleAttributeTrailingSemicolon() {
    Element e = ElementFactory.createDiv();
    String style = "width:12em";
    e.setAttribute("style", style + ";");
    Assert.assertEquals(style, e.getAttribute("style"));
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 64 with Element

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

the class ElementTest method setBooleanAttribute.

@Test
public void setBooleanAttribute() {
    Element e = ElementFactory.createDiv();
    e.setAttribute("foo", true);
    Assert.assertEquals("", e.getAttribute("foo"));
    Assert.assertTrue(e.hasAttribute("foo"));
    e.setAttribute("foo", false);
    Assert.assertEquals(null, e.getAttribute("foo"));
    Assert.assertFalse(e.hasAttribute("foo"));
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 65 with Element

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

the class ElementUtilTest method attachToComponent.

@Test
public void attachToComponent() {
    Element e = ElementFactory.createDiv();
    Component c = Mockito.mock(Component.class);
    ElementUtil.setComponent(e, c);
    Assert.assertEquals(c, e.getComponent().get());
}
Also used : Element(com.vaadin.flow.dom.Element) Component(com.vaadin.flow.component.Component) 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