OrionReed / dom3d

Browser extension to view and debug the DOM in 3D space.
GNU General Public License v3.0
501 stars 11 forks source link

Some elements don't increase stack height #11

Open OrionReed opened 5 months ago

OrionReed commented 5 months ago

Elements like <a> and <i> tags don't appear to have any effect on stack height. This is troublesome because there could be others too. Understanding why this is happening would improve confidence in the rest of the DOM view being accurate.

Note how the tags inside the paragraph here are styled lighter (indicating deeper nesting in the DOM) but do not increase depth.

Screenshot 2024-03-28 at 22 54 12
nozsavsev commented 5 months ago

I experimented a bit and it turns out that any element with 'display: inline' is causing this issue. Usually, inline elements are 'span' 'i' 'strong' 'a' so they are problematic by default, but you can fix it without breaking most of the things by just applying 'inline-block'.
As you can see in the image any elements which are children of display inline will lay flat.

I am still trying to understand how the script works so I won't write a fix at least for now.

Screenshot 2024-03-30 145528 Screenshot 2024-03-30 145548

OrionReed commented 5 months ago

This is great, lead me to some of the transforms spec which notes:

A transformable element is an element in one of these categories:

Which means the ultimate question becomes:

But short term, I'm wondering what mitigation strategies there are, doing something like display: displayCurrent === "inline" ? "inline-block" : displayCurrent might make some headway, but this requires a call to window.getComputedStyle(node) which is incredibly expensive to do for every node.

nozsavsev commented 5 months ago

According to this list of elements that are inline by default https://www.w3schools.com/html/html_blocks.asp

you can use this style

a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, output, q, samp, script, select, small, span, strong, sub, sup, textarea, time, tt, var,  {
    display: inline-block important;
}

I think that if person specifically set something to be inline it should be kept inline, but for elements inline by default this should work