Problem/Motivation
Drupal’s CSS coding standards recommend a naming convention for classes which requires the use of double-underscores as separators in certain cases (BEM). However, when using the views UI to define a view class, underscores will be replaced with dashes. When defining a css class for a specific field, it works as expected.
This is a follow up issue from #2009584: Allow double underscores to pass through drupal_clean_css_identifier as per new CSS standards where artinruins reported the bug. See his screenshots attached. I can confirm this issue:
When adding a class via Edit View > Advanced > CSS, and classname that I add with a "__" double underscore will get rewritten on page render to "--" double hyphens. Drupal 8 is supposedly trying to make BEM (Block Element Modifier) CSS patterns the standard, but this messes with that standard. The accepted BEM pattern is "block__element--modifier".
Proposed resolution
Change the line
<?php
$variables['css_class'] = preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class)
?>
to allow underscores (e.g. by using '/[^a-zA-Z0-9-_ ]/'
for the regex).
Or better, use Html::cleanCssIdentifier().
CSS Changes
Be aware, that fixing this could break layout of existing sites. Specifically when underscores have been used in the main views css class setting.