File tree Expand file tree Collapse file tree
src/main/java/com/flowingcode/vaadin/addons/demo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,10 +224,19 @@ public void apply(HasElement component) {
224224 assertFeatureInitialized ();
225225
226226 VaadinSession .getCurrent ().setAttribute (DynamicTheme .class , this );
227+
228+ String document ;
229+ if (component .getElement ().getTag ().equalsIgnoreCase ("iframe" )) {
230+ document = "this.contentWindow.document" ;
231+ } else {
232+ document = "document" ;
233+ }
234+
227235 component .getElement ().executeJs ("""
236+ const _document = %s;
228237 const applyTheme = () => {
229238 ["lumo/lumo.css", "aura/aura.css"].forEach(href=> {
230- let link = document .querySelector(`link[href='${href}']`);
239+ let link = _document .querySelector(`link[href='${href}']`);
231240 if (!link) return;
232241 if (href === $0) {
233242 if (link.rel === 'preload') link.rel = 'stylesheet';
@@ -238,12 +247,12 @@ public void apply(HasElement component) {
238247 });
239248 };
240249
241- if (document .startViewTransition) {
242- document .startViewTransition(applyTheme);
250+ if (_document .startViewTransition) {
251+ _document .startViewTransition(applyTheme);
243252 } else {
244253 applyTheme();
245254 }
246- """ , href );
255+ """ . formatted ( document ) , href );
247256 }
248257
249258}
You can’t perform that action at this time.
0 commit comments