openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.ui.core.HTML does not preserve IFrame

Open adrian-zguri opened this issue 9 years ago • 3 comments

OpenUI5 version: latest

Browser/version (+device/version): chrome latest

Any other tested browsers/devices(OK/FAIL):

URL (minimal example if possible): https://jsfiddle.net/10p60v08/1/

User/password (if required and possible - do not post any confidential information here): no

Steps to reproduce the problem:

  1. Open an IFrame in a Dialog
  2. Every time the IFrame will load all the dependecies, javascript etc... 3.

What is the expected result? With "preserveDom" I would have expected that the content of the IFrame inside the sap.ui.core.HTML would remain there once loaded.

What happens instead? The content of the IFrame is always loaded.

Any other information? (attach screenshot if possible)

adrian-zguri avatar Jun 27 '17 16:06 adrian-zguri

I'm not an expert, but I know from the past that this used to be impossible in certain browsers. Kind of a security Feature. Not sure if that is still valid.

ThomasChadzelek avatar Jun 27 '17 19:06 ThomasChadzelek

This behavior is indeed defined in the HTML5 spec, see https://www.w3.org/TR/html5/embedded-content-0.html#the-iframe-element:

When an iframe element is inserted into a document, the user agent must create a nested browsing context, and then process the iframe attributes for the "first time".

When an iframe element is removed from a document, the user agent must discard the nested browsing context.

When you search the web, you'll find many discussions of the topic, e.g https://stackoverflow.com/questions/8318264/how-to-move-an-iframe-in-the-dom-without-losing-its-state . The only known option to keep the content of an IFrame alive is not to move (removeChild/appendChild etc.) it in the DOM tree, but only move it visually (using CSS).

This however, is not a feature of the HTML control and definitely not planned. The purpose of the HTML control is to make DOM survive the UI5 rendering process within the limits of the HTML5 spec.

codeworrior avatar Jun 27 '17 19:06 codeworrior

I see. Thank you both for the explanation.

adrian-zguri avatar Jun 28 '17 06:06 adrian-zguri