Open lorenzodallavecchia opened 5 years ago
Hi there 👋
I apologize that it took so long for a member of the Stencil team to respond to this. Unfortunately due to the time gap, the libraries used here are no longer supported. If you're willing & able to, could you please create a new reproduction application for the team to take a look at? If not, I completely understand. I again apologize at the lack of response here, and appreciate the time it took to put something like this together.
Thanks for the issue! This issue has been labeled as needs reproduction
. This label is added to issues that need a code reproduction.
Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.
If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.
For a guide on how to create a good reproduction, see our Contributing Guide.
Thanks for the response, @rwaskiewicz .
I updated the sample to use the latest version of all libraries. However, the problem is still present, with the same reproduction steps.
The problem should be evident in sources: Ionic/Stencil is accessing the global document
and window
variables instead of using the angular DOCUMENT
token to grab the correct document to use.
As was the case when first reporting the bug, I don't know how to reproduce it without Ionic. The problem may be in Stencil itself or caused by how Ionic uses it. This is why I initially reported the problem against Ionic instead of Stencil. The problem also depends on using Stencil with Angular (although, in practice, it may affect other frameworks too).
Please tell me if you have any suggestions for creating a better repro. Thanks.
Bug Report
Ionic version:
[x] 4.9.0
Current behavior:
Ionic fails to render when the Angular app is bootstrapped inside an
iframe
, but with the controlling Angular code kept outside of the frame. Note that the frame has the same origin, so this is likely not a cross-domain issue.Expected behavior:
I would expect the application to render correctly inside the iframe.
Steps to reproduce:
Use the test repository. The basic reproduction scenario is the following.
DOMException
is logged.Another scenario is that of a browser with no support for the
CssStyleSheet
constructor.import "./hacks";
Related code:
Test repository: https://github.com/lorenzodallavecchia/ionic-bug-iframe
Other information:
First of all, I think this is a bug in Stencil, but I could not create a stand-alone reproduction against that project because I have not fully understood how Ionic Angular "bootstraps" Stencil. Sorry about that.
The general issue is that Stencil is accessing the global
document
(and, viadefaultView
, itswindow
), assuming that only a single document exists. I think that it should use theownerDocument
when possible and use that for finding header, body, etc.For example in
addStyle
in the Stencil styles.ts I think it should accept style containers that are DOM documents instead of looking up the root document. Of course that would cause problems with the globalMap
used for saving styles.A trickier issue is
CssStyleSheet
and other constructors. Basically the problem is that an object constructed with the constructor in a window will not be recognized as a validinstanceof
in other windows. DOM methods will simply refuse to append a CSS stylesheet object that they see as "alien".I am aware that my use case is probably an very special one. I would also like to know how you feel about this kind of issues and if a PR would be accepted.
Ionic info: