In particular https://drafts.csswg.org/cssom/#serialize-a-simple-selector doesn't seem to acknowledge that the prefix can also be * and might need to be serialized at times (and not as \*). Also, it's a tad unclear that step 3 and 4 are mutually exclusive.
(This is applicable to both elements and attributes.)