[Bug] Styling broken for Shadow DOM
See original GitHub issueReproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Code
const template = document.createElement('template');
template.innerHTML = `
<style>
#innercontainer {
height: 100%;
}
</style>
<div id="innercontainer">
</div>`;
class MonacoWC extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
connectedCallback() {
const innercontainer = this.shadowRoot.getElementById('innercontainer');
monaco.editor.create(innercontainer, {
value: "function hello() {\n\talert('Hello world!');\n}",
language: 'javascript'
});
}
render() {
}
}
window.customElements.define('monaco-wc', MonacoWC);
const container = document.getElementById('container');
const wcEditor = document.createElement('monaco-wc');
container.append(wcEditor);
Actual Behavior
editor is loaded, however styling is off. lines change order upon scrolling
Expected Behavior
editor should load normally, woth scrolling not affecting lines order.
Additional Context
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
279390 - Cannot inspect styles if an element is in shadow DOM
Append a child element to the shadow root and style it. ... The bug only shows when the styles are in a <style>...
Read more >The ShadowDom css issue with firefox - Bugzilla@Mozilla
Our extension just breaks the page CSS when we were using Shadow Dom with firefox latest version. Is there any work around for...
Read more >Shadow DOM Bug: SVGs don't display correctly
In Safari, shadow DOMs don't render SVGs properly that contain SVG `use` elements. yFiles for HTML uses this feature extensively and thus looks...
Read more >reset style inheritance not working in shadow dom
First of all, the reset-style-inheritance attribute is now obsolete and should not be used. The shadow DOM is now not to be affected...
Read more >Styling in the Shadow DOM With CSS Shadow Parts
Styles can be applied using HTML element selectors like <button> and <div> . These styles could break a component. Shadow DOM is the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the example! I can reproduce, it looks completely broken.
@cameronbraid nice, I confirm that this works. Also I created a simple to use lit based web component, that works out of the box: https://gitlab.com/designestate/dees-editor
Simply put the <dees-editor></dees-editor> component anywhere where you want to have a monaco editor. The API will get more features over the next few days.