]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #11369 (#11402)
authormacprzepiora <maciej@przepiora.me>
Fri, 11 Jan 2019 07:57:44 +0000 (08:57 +0100)
committerOlli Tietäväinen <ollit@vaadin.com>
Fri, 11 Jan 2019 07:57:44 +0000 (09:57 +0200)
Clear contents of iframe clone that is in a Window so that when it's reattached to DOM we don't get 404

client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java

index a2535b4bbe9154d695b4e1721fa358e217663090..46ffa8e432003c94e46bf326d72c34379a6d7b74 100644 (file)
@@ -339,6 +339,22 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
                 }
                 return newEl;
             }
+            if ("iframe".equalsIgnoreCase(old.getTagName()) && old
+                    .hasAttribute("src") && old.getAttribute("src")
+                    .contains("APP/connector")) {
+                // an iframe reloads when reattached to the DOM, but
+                // unfortunately, when newEl is reattached, server-side
+                // resource (e.g. generated PDF) is already gone, so this will
+                // end up with 404, which might be undesirable.
+                // Instead of the resource that is not available anymore,
+                // let's just use empty iframe.
+                // See
+                // https://github.com/vaadin/framework/issues/11369
+                // for details of the issue this works around
+                Element newEl = old.cloneNode(false).cast();
+                newEl.setAttribute("src", "about:blank");
+                return newEl;
+            }
         }
         Node res = node.cloneNode(false);
         if (node.hasChildNodes()) {