HTML_CodeSniffer icon indicating copy to clipboard operation
HTML_CodeSniffer copied to clipboard

Contrast False Positive with Pseudo Elements

Open chavab1 opened this issue 6 years ago • 2 comments

It took me a while to figure out why I was getting a contrast error but I finally figured it out.

I have a button hover effect where the background slides up leaving just the border. The button has a thin border around it, white text, and the background is applied to its ::after selector. On-hover the text changes from white to the dark gray, and the background slides up.

The contrast error that is reported seems to be from the white text in the button against the body's light gray background. So it looks like even though there's a dark gray background, it's not being seeing because it's being rendered by the ::after selector. I confirmed this myself by manually checking the contrast from the white text and light gray background. I got the exact same 1.08:1.

I looked around to see if anyone had experience something similar but I couldn't find anything.

Thanx

capture

chavab1 avatar Mar 23 '18 23:03 chavab1

Reading the code it looks like it doesn't support positioned or pseudo elements at all (will add a failure on absolute positioning). It was a deliberate coding decision probably owing to the difficulty to accurately report on it. I'm going to mark this as an enhancement and will look into it further.

ironikart avatar Mar 25 '18 22:03 ironikart

Thank you for looking into this.

chavab1 avatar Mar 26 '18 16:03 chavab1