May someone explain why the :first-of-type and :last-of-type selectors behave like they do in the following snippet?
https://codepen.io/anon/pen/jaxQNJ
HTML
<div class="container">
<h2 data-type data-type-a>A (should be black / is black)</h2>
<h2 data-type data-type-a>A (should be red / is black)</h2>
<h2 data-type data-type-b>B (should be green / is black)</h2>
<h2 data-type data-type-b>B (should be blue / is blue)</h2>
</div>
CSS
div{
color:black;
font-weight:bold;
}
.container h2[data-type]:last-of-type{
color:blue;
}
.container h2[data-type-a]:last-of-type{
color:red;
}
.container h2[data-type-b]:first-of-type{
color:green;
}