Skip to content

[css-ui][css-pseudo][selection-api] Interop issue: Selecting the default quotes on <q> elements (+implications for selectable pseudo-elements) #12565

@Psychpsyo

Description

@Psychpsyo

The <q> element, by default, has a ::before and an ::after with quotes in it. In all browsers, these do not visually get selected when selecting the text around them. This is because pseudo-elements are currently not selectable in practice, since there's spec issues to resolve regarding copyability and DOM APIs. (see user-select)

In Firefox however, when actually querying the selected text (document.getSelection().toString()) or copying it with Ctrl+C, the resulting string does include quotes. However, this is not the quotes from the pseudos. Any (even partially) selected <q> element causes the copied text to include a " (U+0022 Quotation Mark) before and after the text from the <q> element. This ignores nesting level and Chrome does not do it at all.
EDIT: Nesting level isn't ignored, just reversed, but that's implementation bugs.

This seems like useful functionality and I think it might work as rough precedent for how selectable pseudos ought to be handled. (i.e. They'd be entirely invisible to DOM APIs and just magically inserted into the stringified Selection)
Though the inclusion around partial selections feels weird. Maybe this could get a new CSS property? (select-generated-content: always | in-range where in-range would only include them in a selection if the relevant element boundary is included)
Selections starting or ending inside ::before or ::after pseudos could just be placed around the originating element from the perspective of JS APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions