|
38 | 38 | import org.junit.Test; |
39 | 39 | import org.mockito.Mockito; |
40 | 40 |
|
| 41 | +import com.vaadin.flow.component.Component; |
41 | 42 | import com.vaadin.flow.component.Html; |
42 | 43 | import com.vaadin.flow.component.Tag; |
43 | 44 | import com.vaadin.flow.component.UI; |
@@ -2572,6 +2573,27 @@ public PendingJavaScriptResult executeJs(String expression, |
2572 | 2573 | Assert.assertEquals(Boolean.TRUE, invokedParams.get()[1]); |
2573 | 2574 | } |
2574 | 2575 |
|
| 2576 | + @Test |
| 2577 | + public void givenTypeDefinedArray_ArrayStoreExceptionNotThrown() { |
| 2578 | + Element element = new Element("div") { |
| 2579 | + @Override |
| 2580 | + public PendingJavaScriptResult executeJs(String expression, |
| 2581 | + Serializable... parameters) { |
| 2582 | + Serializable[] wrappedParameters; |
| 2583 | + if (parameters.length == 0) { |
| 2584 | + wrappedParameters = new Serializable[] { this }; |
| 2585 | + } else { |
| 2586 | + wrappedParameters = Arrays.copyOf(parameters, |
| 2587 | + parameters.length + 1, Serializable[].class); |
| 2588 | + wrappedParameters[parameters.length] = this; |
| 2589 | + } |
| 2590 | + return null; |
| 2591 | + } |
| 2592 | + }; |
| 2593 | + |
| 2594 | + element.executeJs("foo", new Component[] { new Div() }); |
| 2595 | + } |
| 2596 | + |
2575 | 2597 | @Test |
2576 | 2598 | public void callFunction_delegatesToCallJsFunction() { |
2577 | 2599 | AtomicReference<String> invokedFuction = new AtomicReference<>(); |
@@ -2632,4 +2654,8 @@ private static ArrayNode createNumberArray(double... items) { |
2632 | 2654 | .collect(JacksonUtils.asArray()); |
2633 | 2655 | } |
2634 | 2656 |
|
| 2657 | + @Tag("div") |
| 2658 | + private static class Div extends Component { |
| 2659 | + } |
| 2660 | + |
2635 | 2661 | } |
0 commit comments