soupsieve
soupsieve copied to clipboard
Modifying :placeholder-shown to handle select > option in certain scenarios
Over at csswg, it appears they plan to add :placeholder-select
.
RESOLVED: Accept and add the :placeholder-select pseudo class and add a note for ::placeholder that we're interested in working on it
~~I don't think they plan to extend :placeholder-shown
to included select options. Anyways, we'll have to wait until something is actually published before we even consider changing :placeholder-shown
or adding :placeholder-select
, but I want to at least track this so I remember to look at it in the future.~~
:placeholder-shown
will be modified based on the wording in the CSS level 4 spec at this time.
When we speak of placeholders and select, we are specifically referring to this case: https://html.spec.whatwg.org/multipage/form-elements.html#placeholder-label-option.
It seems an example has been added over at the CSS drafts page: https://drafts.csswg.org/selectors-4/#placeholder. It mentions:
For example, according to the semantics of [HTML] the placeholder attribute on the input element provide placeholder text, as does the first option element of a select under certain conditions. The :placeholder-shown class thus applies whenever such placeholder text is shown.
So does this mean they are just going to make :placeholder-shown
select the select
case? If so, that makes more sense than adding :placeholder-select
. We'll wait and see how this progresses.
Looking back at the level 4 spec, it appears they mean for :placeholder-shown
to also represent certain option
elements under select
as specified in the HTML spec:
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
This is a new requirement, and I don't think any browsers actually implement new part of :placeholder-shown
yet. So this isn't high priority, but something we should look into.
I will probably wait to see when other browsers implement this. Unfortunately, the csswg takes a looooong time to settle on things and back pedal on things, and if browsers never implement it, stuff gets dropped. It's been years and level 4 still isn't finalized. I may be slower to implement things that browsers aren't implementing moving forward.
If/when we decide to pull the trigger on this, this would essentially get us what we want: https://github.com/facelessuser/soupsieve/tree/feature/placeholder-shown-select.
This functionality seems to have been moved to :blank in the spec. Closing as it seems this will not be relevant to :placeholder-shown.