Would this be more precise and less error prone by testing if the user clicked on an `optgroup` element?

(The current className test assumes that the author doesn't also use the same class for their `option` elements, and assumes that `optgroup` elements will have exactly one class name)