Vaadin 12:将 innerHTML 2x 设置为相同的值不起作用

Vaadin 12: Setting innerHTML 2x to the same value does not work

这是预期的行为吗?

在 "set to 'foo'" 按钮上单击 2 次将导致 innerHTML 变为空。

import java.util.Random;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.router.Route;

@Route("test2")
public class V_Test2 extends Div
{
  public V_Test2()
  {
    Div div = new Div();
    add(div);
    {
      Button button = new Button("set to 'foo'");
      button.addClickListener(e -> div.getElement().setProperty("innerHTML", "foo"));
      add(button);
    }
    {
      Button button = new Button("set random");
      button.addClickListener(e -> div.getElement().setProperty("innerHTML", "bar-" + new Random().nextInt()));
      add(button);
    }
    {
      Button button = new Button("set to null");
      button.addClickListener(e -> div.getElement().setProperty("innerHTML", null));
      add(button);
    }
  }
}

这是一个已知错误:https://github.com/vaadin/flow/issues/4644。您可以通过使用 JavaScript 设置 innerHMTL 值来绕过损坏的逻辑。这将类似于 div.getElement().executeJavaScript("this.innerHTML = [=11=]", "foo");.