GridBackground USS class doesn't work but :GridBackground does?

Hi, following the official documentation on how to use type selectors, I have a USS styleSheet changing the appearance of a GridBackground visualEement:

GridBackground
{	
	--grid-background-color: #222222;
	--line-color: #222222;
	--thick-line-color: #222222;
	--spacing: 20;
}

This class compiles with no errors, but displays no changes in my custom EditorWindow. However, if I add a ‘:’ before ‘GridBackground’, the USS style is applied, even though the console displays a warning:

Unknown pseudo class “GridBackground”

I understand the correct use is ‘GridBackground’, but what I don’t understand is why it is not applied unless I add the ‘:’ . The StyleSheet is properly applied to the VisualElement, so the type selector shouldn’t cause any issue?

I think this an unfortunate consequence that selectors that are only made up of a pseudo state are under the hood treated as wildcard selectors (“*”), with the pseudo state being an extra check on every element. Probably what happens is that the pseudo state being ignored (as per the error) and the selector is applied to all elements, which is clearly wrong.

If you wouldn’t mind logging a bug, we can look into fixing that.

Thanks

1 Like

I’ve sent a bug report. Thank you for your time. Also,

This is exactly what happens, actually; the other VisualElements in the tree are stretched and styled incorrectly without the ‘:’ prefix, which should not happen.