diff --git a/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java b/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java index 291b71d0cce..a85fc05568d 100644 --- a/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java +++ b/flow-client/src/main/java/com/vaadin/client/DependencyLoader.java @@ -260,14 +260,4 @@ private BiConsumer getResourceLoader( "Unknown dependency type " + resourceType); } } - - /** - * Prevents eager dependencies from being considered as loaded until - * HTMLImports.whenReady has been run. - */ - public void requireHtmlImportsReady() { - startEagerDependencyLoading(); - registry.getResourceLoader().runWhenHtmlImportsReady( - DependencyLoader::endEagerDependencyLoading); - } } diff --git a/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java b/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java index fb1a54bc16e..1966a906c68 100644 --- a/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java +++ b/flow-client/src/main/java/com/vaadin/client/ResourceLoader.java @@ -18,7 +18,6 @@ import java.util.function.Supplier; import com.google.gwt.core.client.Duration; -import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.RepeatingCommand; import com.google.gwt.user.client.Timer; @@ -36,7 +35,6 @@ import elemental.html.HeadElement; import elemental.html.LinkElement; import elemental.html.ScriptElement; -import elemental.html.SpanElement; import elemental.html.StyleElement; /** @@ -81,39 +79,6 @@ public void onError(ResourceLoadEvent event) { } } - private class HtmlLoadListener implements ResourceLoadListener, Runnable { - private final ResourceLoadEvent event; - - private boolean errorFired; - - private HtmlLoadListener(ResourceLoadEvent event) { - this.event = event; - } - - @Override - public void run() { - // Invoked through HTMLImports.whenReady - if (!errorFired) { - fireLoad(event); - } - } - - @Override - public void onLoad(ResourceLoadEvent event) { - if (!supportsHtmlWhenReady) { - assert !errorFired; - fireLoad(event); - } - } - - @Override - public void onError(ResourceLoadEvent event) { - assert !errorFired; - errorFired = true; - fireError(event); - } - } - private class SimpleLoadListener implements ResourceLoadListener { @Override public void onLoad(ResourceLoadEvent event) { @@ -213,9 +178,6 @@ public interface ResourceLoadListener { private Registry registry; - private final boolean supportsHtmlWhenReady = GWT.isClient() - && supportsHtmlWhenReady(); - /** * Creates a new resource loader. You should not create you own resource * loader, but instead use {@link Registry#getResourceLoader()} to get an @@ -277,8 +239,7 @@ private void initLoadedResourcesFromDom() { LinkElement linkElement = (LinkElement) links.item(i); String rel = linkElement.getRel(); String href = linkElement.getHref(); - if (("stylesheet".equalsIgnoreCase(rel) - || "import".equalsIgnoreCase(rel)) && href != null + if ("stylesheet".equalsIgnoreCase(rel) && href != null && href.length() != 0) { loadedResources.add(href); // Handle stylesheet loaded by AppShellRegistry @@ -419,115 +380,6 @@ private static HeadElement getHead() { return getDocument().getHead(); } - /** - * Loads an HTML import and notify a listener when the HTML import is - * loaded. Calling this method when the HTML import is currently loading or - * already loaded doesn't cause the HTML import to be loaded again, but the - * listener will still be notified when appropriate. - * - * @param htmlUrl - * url of HTML import to load - * @param resourceLoadListener - * listener to notify when the HTML import is loaded - * @param async - * loads the import asynchronously, if {@code true}, - * synchronously otherwise - */ - public void loadHtml(final String htmlUrl, - final ResourceLoadListener resourceLoadListener, boolean async) { - final String url = WidgetUtil.getAbsoluteUrl(htmlUrl); - ResourceLoadEvent event = new ResourceLoadEvent(this, url); - if (loadedResources.has(url)) { - if (resourceLoadListener != null) { - resourceLoadListener.onLoad(event); - } - return; - } - - if (addListener(url, resourceLoadListener, loadListeners)) { - LinkElement linkTag = getDocument().createLinkElement(); - linkTag.setAttribute("rel", "import"); - linkTag.setAttribute("href", url); - if (async) { - linkTag.setAttribute("async", "true"); - } - - HtmlLoadListener listener = new HtmlLoadListener(event); - - addOnloadHandler(linkTag, listener, event); - getHead().appendChild(linkTag); - - if (supportsHtmlWhenReady) { - addHtmlImportsReadyHandler(listener); - } - } - } - - /** - * Inlines an HTML import and notify a listener when the HTML import is - * loaded. Calling this method when the HTML import is currently loading or - * already loaded doesn't cause the HTML import to be loaded again, but the - * listener will still be notified when appropriate. - * - * @param htmlContents - * the html contents to inline - * @param resourceLoadListener - * listener to notify when the HTML import is loaded - */ - public void inlineHtml(String htmlContents, - final ResourceLoadListener resourceLoadListener) { - ResourceLoadEvent event = new ResourceLoadEvent(this, htmlContents); - if (loadedResources.has(htmlContents)) { - if (resourceLoadListener != null) { - resourceLoadListener.onLoad(event); - } - return; - } - - if (addListener(htmlContents, resourceLoadListener, loadListeners)) { - SpanElement spanElement = getDocument().createSpanElement(); - spanElement.setInnerHTML(htmlContents); - spanElement.setAttribute("hidden", "true"); - - HtmlLoadListener listener = new HtmlLoadListener(event); - getDocument().appendChild(spanElement); - addOnloadHandler(spanElement, listener, event); - - if (supportsHtmlWhenReady) { - addHtmlImportsReadyHandler(listener); - } - } - } - - /** - * Sets the provided task to be run by HTMLImports.whenReady. - * The task is run immediately if HTMLImports.whenReady is not - * supported. - * - * @param task - * the task to run, not null - */ - public void runWhenHtmlImportsReady(Runnable task) { - assert task != null; - if (supportsHtmlWhenReady) { - addHtmlImportsReadyHandler(task); - } else { - task.run(); - } - } - - private static native boolean supportsHtmlWhenReady() - /*-{ - return !!($wnd.HTMLImports && $wnd.HTMLImports.whenReady); - }-*/; - - private static native void addHtmlImportsReadyHandler(Runnable handler) - /*-{ - $wnd.HTMLImports.whenReady($entry(function() { - handler.@Runnable::run()(); - })); - }-*/; - /** * Adds an onload listener to the given element, which should be a link or a * script tag. The listener is called whenever loading is complete or an diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java index cdb16e17c42..f9f5161f345 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -36,7 +36,6 @@ import com.vaadin.client.flow.collection.JsCollections; import com.vaadin.client.flow.collection.JsMap; import com.vaadin.client.flow.collection.JsSet; -import com.vaadin.client.flow.dom.DomApi; import com.vaadin.client.flow.reactive.Reactive; import com.vaadin.flow.shared.ApplicationConstants; import com.vaadin.flow.shared.JsonConstants; @@ -366,18 +365,6 @@ protected void handleJSON(final ValueMap valueMap) { handleDependencies(valueMap.cast()); - if (!initialMessageHandled) { - /* - * When handling the initial JSON message, dependencies are embedded - * in the HTML document instead of being injected by - * DependencyLoader. We must still explicitly wait for all HTML - * imports from the HTML document to be loaded. It's not necessary - * to explicitly wait for JavaScript dependencies since the browser - * already takes care of that for us. - */ - registry.getDependencyLoader().requireHtmlImportsReady(); - } - /* * Hook for e.g. TestBench to get details about server performance */ @@ -385,8 +372,6 @@ protected void handleJSON(final ValueMap valueMap) { serverTimingInfo = valueMap.getValueMap("timings"); } - DependencyLoader.runWhenEagerDependenciesLoaded( - DomApi::updateApiImplementation); DependencyLoader.runWhenEagerDependenciesLoaded( () -> processMessage(valueMap, lock, start)); } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java index 3e2e013771c..1ea26afdf85 100644 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java +++ b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApi.java @@ -15,38 +15,17 @@ */ package com.vaadin.client.flow.dom; -import com.vaadin.client.Console; - import elemental.dom.Node; /** * Access point for DOM API. All operations and interactions with DOM nodes and * elements should go through this class. - *

- * This class delegates the operations to the actual DOM API implementations, - * which might be changed on the run, meaning after dependencies have been - * loaded. * * @author Vaadin Ltd * @since 1.0 */ public class DomApi { - /** - * Flag for tracking if Polymer-micro.html is loaded (contains dom). - * - * Package protected for testing reasons. - */ - static boolean polymerMicroLoaded = false; - - /** - * The currently used DOM API implementation. By default just returns the - * same object. - * - * Package protected for testing reasons. - */ - static DomApiImpl impl; - private DomApi() { // NOOP } @@ -60,25 +39,7 @@ private DomApi() { * @return a wrapped element */ public static DomElement wrap(Node node) { - if (impl == null) { - return (DomElement) node; - } - return impl.wrap(node); - } - - /** - * Updates the DOM API implementation used. - */ - public static void updateApiImplementation() { - if (!polymerMicroLoaded && PolymerDomApiImpl.isPolymerMicroLoaded()) { - polymerMicroLoaded(); - } - } - - private static void polymerMicroLoaded() { - polymerMicroLoaded = true; - Console.debug("Polymer micro is now loaded, using Polymer DOM API"); - impl = new PolymerDomApiImpl(); + return (DomElement) node; } } diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java deleted file mode 100644 index 74a1f185c92..00000000000 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/DomApiImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2026 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.flow.dom; - -import elemental.dom.Node; - -/** - * A DOM API abstraction layer to be used via {@link DomApi#wrap(Node)}. - * - * @author Vaadin Ltd - * @since 1.0 - */ -@FunctionalInterface -public interface DomApiImpl { - - /** - * Wraps the given DOM node to make it safe to invoke any of the methods - * from {@link DomNode} or {@link DomElement}. - * - * @param node - * the node to wrap - * @return the wrapped element - */ - DomElement wrap(Node node); -} diff --git a/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java b/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java deleted file mode 100644 index 8d9abcef1a4..00000000000 --- a/flow-client/src/main/java/com/vaadin/client/flow/dom/PolymerDomApiImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2000-2026 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.client.flow.dom; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; - -import elemental.dom.Node; - -/** - * Implementation of {@link DomApiImpl} that uses the - * Polymer - * 's DOM API. - *

- * Contains methods for checking whether polymer-micro.html has been loaded. - * - * @author Vaadin Ltd - * @since 1.0 - */ -public class PolymerDomApiImpl implements DomApiImpl { - - @Override - public DomElement wrap(Node node) { - return getPolymer().dom(node); - } - - /** - * Checks whether the polymer-micro.html is loaded or not. - * - * @return true if polymer micro has been loaded, - * false if not - */ - public static boolean isPolymerMicroLoaded() { - // Don't use the impl with Polymer 2 - return getPolymer() != null - && getPolymer().getVersion().startsWith("1."); - } - - /** - * A reference to the native Polymer object in JavaScript. - */ - @JsType(isNative = true) - interface Polymer { - - /** - * A Polymer - * .dom method java representation. Wraps a Node so - * that it works with Polymer based web components. - * - * @param node - * the node to wrap to Polymer dom - * @return the wrapped node - */ - DomElement dom(Node node); - - /** - * Returns polymer version. - * - * @return polymer version - */ - @JsProperty - String getVersion(); - - } - - /** - * Returns a reference to the native Polymer object in JavaScript. - *

- * The existence of this object can be used to check whether - * polymer-micro.html has been loaded. - * - * @return the polymer object, or null if polymer micro has not - * been loaded - */ - @JsProperty(namespace = JsPackage.GLOBAL, name = "Polymer") - private static native Polymer getPolymer(); - -} diff --git a/flow-client/src/test-gwt/java/com/vaadin/client/GwtDependencyLoaderTest.java b/flow-client/src/test-gwt/java/com/vaadin/client/GwtDependencyLoaderTest.java index 94c7b5e8872..d21068fb7f1 100644 --- a/flow-client/src/test-gwt/java/com/vaadin/client/GwtDependencyLoaderTest.java +++ b/flow-client/src/test-gwt/java/com/vaadin/client/GwtDependencyLoaderTest.java @@ -50,14 +50,6 @@ private MockResourceLoader() { List loadingStyles = new ArrayList<>(); List loadingScripts = new ArrayList<>(); - List loadingHtml = new ArrayList<>(); - - @Override - public void loadHtml(String htmlUrl, - ResourceLoadListener resourceLoadListener, boolean async) { - loadingHtml.add(htmlUrl); - resourceLoadListener.onLoad(new ResourceLoadEvent(this, htmlUrl)); - } @Override public void loadScript(String scriptUrl, @@ -82,14 +74,6 @@ public void loadStylesheet(String stylesheetUrl, .onLoad(new ResourceLoadEvent(this, stylesheetUrl)); } - @Override - public void inlineHtml(String htmlContents, - ResourceLoadListener resourceLoadListener) { - loadingHtml.add(htmlContents); - resourceLoadListener - .onLoad(new ResourceLoadEvent(this, htmlContents)); - } - @Override public void inlineScript(String scriptContents, ResourceLoadListener resourceLoadListener) { diff --git a/flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java b/flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java index eb601132421..dbb6377ce4e 100644 --- a/flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java +++ b/flow-client/src/test-gwt/java/com/vaadin/client/GwtSuite.java @@ -20,8 +20,6 @@ import com.vaadin.client.flow.collection.GwtJsMapTest; import com.vaadin.client.flow.collection.GwtJsSetTest; import com.vaadin.client.flow.collection.GwtJsWeakMapTest; -import com.vaadin.client.flow.dom.GwtDomApiTest; -import com.vaadin.client.flow.dom.GwtPolymerApiImplTest; import com.vaadin.client.flow.util.GwtClientJsonCodecTest; import com.vaadin.client.flow.util.GwtNativeFunctionTest; @@ -45,8 +43,6 @@ public static Test suite() { suite.addTestSuite(GwtNativeFunctionTest.class); suite.addTestSuite(GwtStateNodeTest.class); suite.addTestSuite(GwtStateTreeTest.class); - suite.addTestSuite(GwtDomApiTest.class); - suite.addTestSuite(GwtPolymerApiImplTest.class); suite.addTestSuite(GwtWidgetUtilTest.class); suite.addTestSuite(GwtExecuteJavaScriptElementUtilsTest.class); suite.addTestSuite(GwtDependencyLoaderTest.class); diff --git a/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtDomApiTest.java b/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtDomApiTest.java deleted file mode 100644 index 9a2ce358c7a..00000000000 --- a/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtDomApiTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.vaadin.client.flow.dom; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.core.client.impl.SchedulerImpl; -import com.vaadin.client.ClientEngineTestBase; -import com.vaadin.client.DependencyLoader; -import com.vaadin.client.Registry; -import com.vaadin.client.ResourceLoader; -import com.vaadin.client.UILifecycle; -import com.vaadin.client.UILifecycle.UIState; -import com.vaadin.client.ValueMap; -import com.vaadin.client.communication.LoadingIndicatorStateHandler; -import com.vaadin.client.communication.MessageHandler; -import com.vaadin.client.communication.MessageSender; -import com.vaadin.client.communication.RequestResponseTracker; -import com.vaadin.client.communication.ServerRpcQueue; - -public class GwtDomApiTest extends ClientEngineTestBase { - - private Registry registry; - - @Override - protected void gwtSetUp() throws Exception { - super.gwtSetUp(); - - registry = new Registry() { - { - UILifecycle uiLifecycle = new UILifecycle(); - uiLifecycle.setState(UIState.RUNNING); - set(UILifecycle.class, uiLifecycle); - set(RequestResponseTracker.class, - new RequestResponseTracker(this)); - set(MessageHandler.class, new MessageHandler(this)); - set(MessageSender.class, new MessageSender(this)); - set(ServerRpcQueue.class, new ServerRpcQueue(this)); - set(DependencyLoader.class, new DependencyLoader(this)); - set(ResourceLoader.class, new ResourceLoader(this, false)); - set(LoadingIndicatorStateHandler.class, new LoadingIndicatorStateHandler(this)); - } - - }; - - registry.getRequestResponseTracker().startRequest(); - } - - private void initTest() { - DomApi.polymerMicroLoaded = false; - DomApi.impl = node -> (DomElement) node; - - initScheduler(new SchedulerImpl() { - @Override - public void scheduleDeferred(ScheduledCommand cmd) { - } - }); - - GwtPolymerApiImplTest.clearPolymer(); - - verifyPolymerDomApiUsed(false); - verifyPolymerMicroLoaded(false); - } - - public void testPolymerMicroDependencyLoaded() { - initTest(); - - GwtPolymerApiImplTest.setPolymerMicro(); - - startMessageHandling(); - - verifyPolymerDomApiUsed(true); - verifyPolymerMicroLoaded(true); - } - - public void testPolymerFullDependencyLoaded() { - initTest(); - - GwtPolymerApiImplTest.setPolymerFull(); - - startMessageHandling(); - - verifyPolymerDomApiUsed(true); - verifyPolymerMicroLoaded(true); - } - - private void startMessageHandling() { - JavaScriptObject message = JavaScriptObject.createObject(); - - registry.getMessageHandler().handleMessage((ValueMap) message); - } - - private void verifyPolymerDomApiUsed(boolean used) { - assertEquals( - "PolymerDomApi should " + (used ? "" : "not ") + "be in use", - used, DomApi.impl.getClass().equals(PolymerDomApiImpl.class)); - } - - private void verifyPolymerMicroLoaded(boolean used) { - assertEquals( - "PolymerMicro should " + (used ? "" : "not ") + "be in use", - used, DomApi.polymerMicroLoaded); - } - - private native void initScheduler(SchedulerImpl scheduler) - /*-{ - @com.google.gwt.core.client.impl.SchedulerImpl::INSTANCE = scheduler; - }-*/; - -} diff --git a/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtPolymerApiImplTest.java b/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtPolymerApiImplTest.java deleted file mode 100644 index 9ec0449bdf1..00000000000 --- a/flow-client/src/test-gwt/java/com/vaadin/client/flow/dom/GwtPolymerApiImplTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.vaadin.client.flow.dom; - -import com.vaadin.client.ClientEngineTestBase; -import com.vaadin.client.WidgetUtil; -import com.vaadin.client.flow.dom.PolymerDomApiImpl.Polymer; -import com.vaadin.client.flow.util.NativeFunction; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; - -public class GwtPolymerApiImplTest extends ClientEngineTestBase { - - @JsProperty(namespace = JsPackage.GLOBAL, name = "Polymer") - private static native void setPolymer(Polymer polymer); - - static void setPolymerFull() { - setPolymerMicro(); - } - - static void setPolymerMicro() { - setPolymerVersion("1.9.1"); - } - - static void setPolymerVersion(String version) { - NativeFunction function = NativeFunction - .create("return { 'version': '" + version + "' };"); - setPolymer(WidgetUtil.crazyJsCast(function.call(null))); - } - - static void clearPolymer() { - setPolymer(null); - } - - private void initTest() { - clearPolymer(); - verifyPolymerMicro(false); - } - - public void testPolymerMicroLoaded() { - initTest(); - - setPolymerVersion("1.9.1"); - - verifyPolymerMicro(true); - } - - public void testPolymer2() { - initTest(); - - setPolymerVersion("2.0.2"); - - verifyPolymerMicro(false); - } - - private static void verifyPolymerMicro(boolean loaded) { - assertEquals( - "Polymer micro should " + (loaded ? "" : "not ") + "be loaded", - loaded, PolymerDomApiImpl.isPolymerMicroLoaded()); - } - -} diff --git a/flow-client/src/test/java/com/vaadin/client/DependencyLoaderTest.java b/flow-client/src/test/java/com/vaadin/client/DependencyLoaderTest.java index a610cb40558..5c3606dc780 100644 --- a/flow-client/src/test/java/com/vaadin/client/DependencyLoaderTest.java +++ b/flow-client/src/test/java/com/vaadin/client/DependencyLoaderTest.java @@ -49,14 +49,6 @@ private MockResourceLoader() { List loadingStyles = new ArrayList<>(); List loadingScripts = new ArrayList<>(); - List loadingHtml = new ArrayList<>(); - - @Override - public void loadHtml(String htmlUrl, - ResourceLoadListener resourceLoadListener, boolean async) { - loadingHtml.add(htmlUrl); - resourceLoadListener.onLoad(new ResourceLoadEvent(this, htmlUrl)); - } @Override public void loadScript(String scriptUrl, @@ -81,14 +73,6 @@ public void loadStylesheet(String stylesheetUrl, .onLoad(new ResourceLoadEvent(this, stylesheetUrl)); } - @Override - public void inlineHtml(String htmlContents, - ResourceLoadListener resourceLoadListener) { - loadingHtml.add(htmlContents); - resourceLoadListener - .onLoad(new ResourceLoadEvent(this, htmlContents)); - } - @Override public void inlineScript(String scriptContents, ResourceLoadListener resourceLoadListener) {