sap.ui.core.HTML binding content issue
See original GitHub issueOpenUI5 version: 1.52.5
Browser/version (+device/version): Chrome
Any other tested browsers/devices(OK/FAIL): No
URL (minimal example if possible): https://ui5issues-a854a7813.dispatcher.hana.ondemand.com/index.html?hc_reset#/objectpagelayout
Steps to reproduce the problem: If i am binding the html markup using
<core:HTML content="{ui>/html}" sanitizeContent="true"/>
after changing the value, the bound html will be appended instead of replaced.
You can reporduce this in my example by triggering the section action “setHTML” which does
this._oViewModel.setProperty("/html", this._sHTML + "<b>" + Date.now() + "</b>");
What is the expected result? html code will be replaced
What happens instead? html code will be appended. The same line will be shown multiple times (to recognize this, i added Date.now() to the output).
Regards Holger
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
HTML Component - Binding issue - SAP Community
I am trying to bind the HTML component content attribute with data returned from an OData service. I made sure that the OData...
Read more >Data binding for HTML in XMLView - SAP Community
Hi, Is there any way to bind data from a model to the native HTML tag in an XML view? Below is an...
Read more >SAPUI5 sap.ui.core HTML rendering redirecting on binding ...
Dear Experts, I am using sap.ui.core.HTML link , I am binding custom HTML coming from the external service that I am saving in...
Read more >Data Binding not working - SAP Community
We are trying to bind data from controller to view but for some reason We are unable to display data in the view....
Read more >Does data binding works on html element <html:div>
I know we could do property, element, aggregation binding in SAPUI5. new sap . ui . commons . TextField ({ value: "{name}" })...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When you increase the log level so that UI5 also logs warnings, you’ll notice that the HTML control complains about the content that it receives:
[Unsupported Feature]: Element sap.ui.core.HTML#__html0 has rendered 5 root nodes!
If multiple root elements are given, the UI5 re-rendering doesn’t work. The HTML control only issues a warning in this case as in the past we had some use cases that didn’t require re-rendering.
Nevertheless, I wondered about the number of 5 root nodes. This seems to be caused by the content string:
<p><h2>This is my headline...</h2><br/>text</p>
According to the HTML5 spec, the content model for
<p>
is phrasing content, but<h2>
is no phrasing content. Furthermore, the spec allows to omit the closing</p>
when e.g.<h2>
tag follows. So the browser parses the string automatically as<p></p> <h2>This is my headline...</h2> <br> text <p></p>
which indeed gives 5 root nodes (one of them a text node).
When I change the wrapper to a
<div>
instead of<p>
and pay attention that setHtml also creates the same (and does not append another root node<b>
), then it works as expected.That’s what I meant with my last comment:
For compatibility reasons, we can’t always add a wrapper.