Hi Marijin,
I have integrated codemirror into prosemirror. For CSS collisions in various products, we have implemented our prosemirror editor inside shadow-DOMs. There may be cases where we might use multiple editors within the same page under different shadow-DOMs.
So when doing so found that codemirror’s CSS is getting injected into one shadow dom only for the first time in the page, when another codemirror instance is created in another shadow-DOM, the expectation is to inject the CSS again into that shadow-DOM as well, but in the below attached video you can see that the CSS is not getting applied into the second shadow-DOM.
All the classes are getting attached properly to both codemirror instances, but the CSS alone is not getting applied into the second shadow-DOM, on debugging further found that in style-mod package in this line, seems like the doc variable is assigned the wrong value. Probably it should have been like let doc = root || root.ownerDocument , this is because of the reason that root.ownerDocument always points to the top level document irrespective of, in which shadow root the codemirror instance is present. As a result, for the first time adoptedSet Map has no value so codemirror’s styles are getting injected, but from the second time since root.ownerDocument points to the top level document, irrespective of which shadow root you pass, always adoptedSet Map says the CSS is injected into that particular doc key, as a result the CSS is not getting injected into the second shadow-root.
If that is the issue, can I submit a PR with the patch for it @marijn ?
You can find the video here