Custom Elements are not getting marked when hovering over them with Chrome DevTools

J. Doe

I have a main html file where i embedd Web Components. When debugging I noticed, that my Custom Elements are not marked, when I hover over them. enter image description here

Im also not able to set the size of the custom html element from an outisde css.

Here is my code:

view.html

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link href="view.css" rel="stylesheet" />
    <script defer src="widget-uhr.js"></script>
</head>

<body>
    <widget-uhr></widget-uhr>
    <widget-uhr></widget-uhr>
    <widget-uhr></widget-uhr>
    <button>View Button</button>
</body>
</html>

widget-uhr.html

   <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link href="widget-uhr.css" rel="stylesheet" />
</head>

<body>
    <div id="time"></div>
    <button>Widget Button1</button>
    <button>Widget Button2</button>
    <button>Widget Button3</button>
</body>
</html>

view.css

body{
    display:block;
}
button{
    min-width: 250px;
    min-height: 100px;
    background-color: aqua;
    font-size: 32px;
}

widget-uhr.css

body{
color:green;
background-color: gray;
}

div{
    color:blue;
    background-color: gray;
}

button{
    background-color: red;
}

widget-uhr.js

fetch( "widget-uhr.html" )
    .then( stream => stream.text() )
    .then( text => 
        customElements.define( "widget-uhr", class extends HTMLElement {
            constructor() {
                super()
                this.attachShadow( { mode: 'open'} )
                    .innerHTML = text


            }
        } )
    )

Is the reason maybe because I inject my html from the widget via fetch?

Supersharp

By default a Custom Element is inline, so it won't be marked in Dev Tools.

To get it marked, you should define its CSS display propery to block or inline-block.

From inside its Shadow DOM, use the :host CSS pseudo-class.

In widget-uhr.css:

:host { display: block }

Or, from the main document, use the custom element name.

In view.css:

widget-uhr { display: block }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to change the style of other elements when hovering over one of them?

Getting SVG elements to animate when hovering over a different element using keyframes

Making Materialize CSS Tooltips stay when hovering over them

Getting 2 divs to change colour when hovering over 1 div

How to stop the elements from growing when hovering over an element?

How to change a plot when hovering over elements in Shiny?

Only fire one onmouseover when hovering over multiple elements

Chrome fixed div disappearing when hovering over links

Adding a transition effect when hovering over a custom CSS checkbox

Add custom text when hovering over each row of datatable

How do I style two elements into different styles by hovering over one of them? Without JavaScript

'Hovering' elements when clicked

Why is parts of the css hover color getting left over when hovering over links?

How to have a div show up when hovering over elements but not appear over the mouse pointer?

In a network graph, how do I highlight the network components when hovering over them?

How do I change the class of several tds when hovering over one of them?

why does my custom-made "cursor" falls behind the moving div elements when i hover over them?

Flickering tooltip when hovering over it

Popover not hide when hovering over it

Show text over a image when hovering over it

GUI elements are only shown when mouse is moved over them

My li elements move downwards when I hover over them

Hovering makes elements appear over each other

Javascript: How do i target selected elements in a slideshow when hovering over one element?

How to use tailwindcss to change the color of each element when hovering over descendant elements

Google Data Studio - Custom Metrics and Drill Down Options When Hovering Over Graph

Divs jitter when hovering between them quickly

Fix position of elements when hovering on other elements

How to select specific list items in a list and add a line through property when mouse is hovering/clicking over them in Javascript