-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only do hookUpPolymerElement for Polymer elements (#4147)
* Only do hookUpPolymerElement for Polymer elements
- Loading branch information
Showing
6 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ts/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/CustomCustomElementView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2000-2018 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.uitest.ui; | ||
|
||
import com.vaadin.flow.component.dependency.JavaScript; | ||
import com.vaadin.flow.component.html.NativeButton; | ||
import com.vaadin.flow.dom.Element; | ||
import com.vaadin.flow.router.Route; | ||
import com.vaadin.flow.uitest.servlet.ViewTestLayout; | ||
|
||
@Route(value = "com.vaadin.flow.uitest.ui.CustomCustomElementView", layout = ViewTestLayout.class) | ||
@JavaScript("frontend://com/vaadin/flow/uitest/ui/CustomCustomElement.js") | ||
public class CustomCustomElementView extends AbstractDivView { | ||
|
||
public CustomCustomElementView() { | ||
Element element = new Element("custom-custom-element"); | ||
element.getStyle().set("display", "block"); | ||
|
||
element.setProperty("property", "initial"); | ||
|
||
getElement().appendChild(element); | ||
|
||
add(new NativeButton("update property", | ||
event -> element.setProperty("property", "updated"))); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...st-root-context/src/main/webapp/frontend/com/vaadin/flow/uitest/ui/CustomCustomElement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// A custom element that isn't using Polymer | ||
class CustomCustomElement extends HTMLElement { | ||
static get is() { return 'custom-custom-element' } | ||
|
||
constructor() { | ||
super(); | ||
this.attachShadow({mode: "open"}); | ||
this.property = "constructor"; | ||
} | ||
|
||
set property(value) { | ||
this.shadowRoot.textContent = value; | ||
} | ||
|
||
get property() { | ||
return this.shadowRoot.textContent; | ||
} | ||
} | ||
customElements.define(CustomCustomElement.is, CustomCustomElement); |
46 changes: 46 additions & 0 deletions
46
...ests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/CustomCustomElementIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2000-2017 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.uitest.ui; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
|
||
import com.vaadin.flow.testutil.ChromeBrowserTest; | ||
import com.vaadin.testbench.TestBenchElement; | ||
|
||
public class CustomCustomElementIT extends ChromeBrowserTest { | ||
|
||
@Before | ||
public void setUp() { | ||
open(); | ||
} | ||
|
||
@Test | ||
public void clickOnButton_removeFromLayout() { | ||
TestBenchElement customElement = $("custom-custom-element").first(); | ||
|
||
Assert.assertEquals("initial", | ||
customElement.getPropertyString("shadowRoot", "textContent")); | ||
|
||
findElement(By.tagName("button")).click(); | ||
|
||
Assert.assertEquals("updated", | ||
customElement.getPropertyString("shadowRoot", "textContent")); | ||
} | ||
|
||
} |