summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2013-05-08 09:31:09 +0300
committerMarc Englund <marc@vaadin.com>2013-05-08 09:31:09 +0300
commit1b188073c46c5c21bb8ddeb21674452c9bc414fd (patch)
treeffd26aebca49b4372cdbeb472e6a916e8249167f /client
parent7d9f544d584edb90b1c9231987e356dfaf0b7b35 (diff)
downloadvaadin-framework-1b188073c46c5c21bb8ddeb21674452c9bc414fd.tar.gz
vaadin-framework-1b188073c46c5c21bb8ddeb21674452c9bc414fd.zip
Remove pre-loader element after pre-loading, fixes #10863
Change-Id: Ibd2009315aadb25e574c82f3b4b54c501d9b1395 Ticket: 10863
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ResourceLoader.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ResourceLoader.java b/client/src/com/vaadin/client/ResourceLoader.java
index b3b9ac7256..7fc8b4f9f3 100644
--- a/client/src/com/vaadin/client/ResourceLoader.java
+++ b/client/src/com/vaadin/client/ResourceLoader.java
@@ -50,8 +50,8 @@ public class ResourceLoader {
* Event fired when a resource has been loaded.
*/
public static class ResourceLoadEvent {
- private ResourceLoader loader;
- private String resourceUrl;
+ private final ResourceLoader loader;
+ private final String resourceUrl;
private final boolean preload;
/**
@@ -286,25 +286,35 @@ public class ResourceLoader {
// Inject loader element if this is the first time this is preloaded
// AND the resources isn't already being loaded in the normal way
- Element element = getPreloadElement(url);
+ final Element element = getPreloadElement(url);
addOnloadHandler(element, new ResourceLoadListener() {
@Override
public void onLoad(ResourceLoadEvent event) {
fireLoad(event);
+ Document.get().getBody().removeChild(element);
}
@Override
public void onError(ResourceLoadEvent event) {
fireError(event);
+ Document.get().getBody().removeChild(element);
}
}, event);
- // TODO Remove object when loaded (without causing spinner in FF)
Document.get().getBody().appendChild(element);
}
}
private static Element getPreloadElement(String url) {
+ /*-
+ * TODO
+ * In Chrome, FF:
+ * <object> does not fire event if resource is 404 -> eternal spinner.
+ * <img> always fires onerror -> no way to know if it loaded -> eternal spinner
+ * <script type="text/javascript> fires, but also executes -> not preloading
+ * <script type="text/cache"> does not fire events
+ * XHR not tested - should work, probably causes other issues
+ -*/
if (BrowserInfo.get().isIE()) {
ScriptElement element = Document.get().createScriptElement();
element.setSrc(url);