question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Styling broken for Shadow DOM

See original GitHub issue

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

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:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hedietcommented, Mar 14, 2022

Thanks for the example! I can reproduce, it looks completely broken.

0reactions
philkunzcommented, May 18, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found