The :only-child matches every first child and the :only-of-type selector matches every first child of a new type.
The reason for this is that every time a new element is added to the DOM, it is checked to see if it matches one of the CSS selectors. Because the DOM is build one element at a time, every first child is at least for a moment the only child. The same applies to the first element of a certain type. It is at least for a moment the only of that type.
The :only-child selector should only match elements that are *really* the only child. The :only-of-type selector should only match elements that are *really* the only child of a certain type. Once an element is no longer the only, or the only of a certain type, it should no longer match these selectors.
*** This bug has been marked as a duplicate of 5468 ***