UiBinder - HTMLPanel vs. div

自闭症网瘾萝莉.ら 提交于 2019-12-04 23:38:34
Thomas Broyer

Short answer:

When in doubt, look at the generated code (pass the -gen argument to the DevMode or Compiler)

Long answer:

There will be a runtime performance penalty using a widget over a simple DOM element, always. And even more when that DOM element is created by parsing an HTML snippet.

When UiBinder sees a widget as a child of HTMLPanel, it will generate a placeholder <span> with a generate unique ID and then use the HTMLPanel.addAndReplaceElement to replace that placeholder with a widget.

So the second snippet will generate (approx)

HTMLPanel root = new HTMLPanel("<span id='uuid'></span>");
HTMLPanel child = new HTMLPanel("/* Widgets, more HTML. */");
root.addAndReplaceElement(child, "uuid");

This isn't a performance penalty, but I think HTMLPanel is the only Widget that, within a UiBinder, can contain (as children) a mix of both Widget and HTML tags.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!