New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering of preserved content #1162
Comments
Short answer: Long version: Your observations touch several aspects of UI5 rendering. So it might be best to give an overview about UI5 rendering mechanisms before explaining the preserve mechanism:
You might ask (you indeed did), why DOM preservation is necessary at all. Why not leave the DOM alone, not touching it? The problem is with the first rendering variant, string based rendering. When some parent of the What to do now? Depending on what you want to achieve you might just accept the existing behavior (hopefully after getting a better understanding of it now), or you might move to the HTML control (as it allows you to use pure HTML but without preservation) or you might consider to write your own control (should be necessary only for very special use cases, but then please without DOM preservation, it's not a public feature for control development). Last but not least: this is an explanation of the current state of the rendering. For sure there are other ways of implementing it. There've been experiments with a general DOM patching ( 26309b5 ) using the current renderers. And some other experiments with the use of virtual DOM. However, the huge amount of existing renderer code makes the introduction of new mechanisms quite challenging. Well, I obviously violated your "a little bit" constraint a little bit, but hope this nevertheless helps to understand why DOM nodes might be moved around. |
@codeworrior Many thanks for this thorough description. |
|
I think you have to explain your scenario a bit more. Is the deletion of the previous item in the aggregation done on model level and the list binding updates the But if you just remove an item via aggregation API, IDs should not change. |
I see. I fear, the aggregation binding's standard behavior doesn't work together with the HTML control's constraint reg. the ID / content ID. There's no such mechanism to decouple Is the A factory function gets the binding context as 2nd parameter and could determine the |
The aggregation API is good enough for me. I tried doing it with factory, but the result is the same (the content of the core.HTML is the initially provided string, not the preserved DOM) fnFactory: function (sId, oContext) { const oControl = this.byId("templateItem").clone(sId); try { oControl.setContent( new sap.ui.core.HTML(oContext.getObject("globalId"), { content: "div id='{local>globalId}' /div", }) ); } catch (e) { console.log(e); } return oControl; }, |
Well, as I said, aggregation binding and HTML control don't work well together:
To demonstrate these problems' I've created a JSBin: https://jsbin.com/sewekisono/edit?html,output |
I used sap.ui.getCore().applyChanges() in my JSBin to be sure that rendering already happened before I apply the dynamic HTML. Using it in a productive app is in general not recommended as sync rendering is a kind of de-optimization. Async rendering collects updates and handles them at once, e.g. avoiding multiple rendering of the same control. Sync rendering - when triggered by multiple components not knowing each other - might cause such redundant rendering or other side effects. But when you see benefit in your scenario and do this only after deletion of a chart, you can IMO use it, it is a public API. |
I have quite a hard time to understand why the RenderManager moves a node to the so called "preserved area". Could you elaborate on this feature a little bit?
The problem is that I am doing some parts of the initialization in onAfterRendering of the controller. I expect that the view is only rendered once i.e. added to the DOM. Unfortunately onAfterRendering is often called twice (e.g. when navigating back):
It is also called when a node is moved from the (hidden) "sap-ui-preserve" div to the top container if the view gets visible (upon navigation).
So far so good (? - why is it "re-rendered" if it is already in the DOM. It is just invisible)
Yet I can not find a rule when and why a node is moved to "sap-ui-preserve" and therefore later "re-rendered". Sometimes the node (the view) stays in the top container sometime s not. Is it possible to force a node NOT to be moved to "sap-ui-preserve"?
OpenUI5 version:
1.38.4
Browser/version (+device/version):
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36
The text was updated successfully, but these errors were encountered: