SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.94k stars 1.23k forks source link

The control core.HTML confounds the content of two consecutive render cycles the old HTML and the new one #3952

Closed maiargu closed 7 months ago

maiargu commented 7 months ago

URL (minimal example if possible): https://jsfiddle.net/maiagru/fr4L6exu/3/

Steps to reproduce the problem:

  1. set content for a core:HTML component with property preferDOM="false"

  2. html is rendered fine image

  3. set content for the second time by pressing the button "Add HTML" in the provided example jsfiddle

  4. the html gets mixed up because previous lines from the previous rendering are still maintained instead of being destroyed image

What is the expected result? Expected result is to see as html content for the second rendering only the lines

a

b

c

What happens instead? In the second rendering

b

c from the previous rendering are appended to the current rendering.

Any other information? (attach screenshot if possible) Maybe related https://github.com/SAP/openui5/issues/3683

codeworrior commented 7 months ago

Your HTML content consists of more than one root element. This is not supported by the HTML control. Wrap the content in e.g. a <div> and rendering behaves as you expect it.

The documentation for the content property states:

The HTML control currently doesn't prevent the usage of multiple root nodes in its DOM content (e.g. setContent("

")), but this is not a guaranteed feature. The accepted content might be restricted to single root nodes in future versions. To notify applications about this fact, a warning is written in the log when multiple root nodes are used.

maiargu commented 7 months ago

Thanks, proposed solution to wrap everything in a parent <div> tag works.