Short Answer
No real mystery here, the white text is better actual perceived contrast, and WCAG2 does not accurately reflect this. This is partly because WCAG2 contrast math is not perceptually uniform, is not sensitive to polarity (dark mode vs light mode), and does not help with color vision deficiencies.
Longer Answer
The deficiencies and issues with WCAG2 contrast are fairly well-known, especially in more recent years. Significant work has been done and continues to be done to develop replacement technologies. Even though this is an old question I am providing this update answer because this is a changing situation today.
In the case of the lavender on the JFiddle background: #8C82B9;
, white text has about 70% more contrast than black text. The following image is a clinically accurate simulation of various forms of color vision deficiency, and also one of actual color blindness also known as achromatopsia in this case it is a simulation of blue cone monochromatism.
Simulation by Myndex CVD Sim
This shows that various color sensitive vision types see this simple graphic equally well. The very rare forms of actual color blindness (BCM 1/100,000 shown here) is co-morbid with photophobia and low vision, and generally require some level of AT.
Follow Accessible Road 🎶
As far as "do you have to follow WCAG2" or can you follow newer developing guidelines that are not yet official recommendations? The answer is it depends, depending on what your specific contractual or legal obligations are for your product & market, and that will somewhat dictate which contrast technology you need to follow.
The color scheme modes used also affects certain legal obligations—that is, if you have a light-mode following weekend too and there's a user selectable choice of other color schemes, other color and contrast methods can be used. This is important because WCAG2 cannot calculate for dark mode, while APCA can.
In the United States the ADA does not specify WCAG2, only that public accommodations be accessible. However government procurement must follow the US Access Board 508 rule, which generally uses WCAG2. It's important to know though that the 508 rule has a couple of important exceptions:
- commercial availability (if procuring IT technology like an application and it doesn't meet 508/WCAG2, it can still be purchased, provided that a more accessible version is not commercially available)
- alternate facilitation (using an alternate technology to provide contrast guidance can be used, so long as accessibility is enhanced.)
This second rule, alternate facilitation, allows for APCA to be used as an alternate facilitation, as APCA is more accurate and better promotes actual accessibility.
The regulations are different in Europe and some other parts of the world, so it's important to know what your actual requirements are for your market. If you do have a specific requirement, there is an interim guideline called BridgePCA, which provides backwards compatibility to WCAG2, at the expense of flexibility. For instance with this lavender, BridgePCA rejects the black text and allows white text, so long as the text is large.
Disclaimer: while I am an invited expert of W3C, opinions expressed are my own and not necessarily those of the W3C. Also, I am the creator of APCA and BridgePCA, being developed to replace the older WCAG2.