Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Flat Tree or Composed Tree

Abierto
#336 8 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
20/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
html
Área
api, frontend, web-dev

Línea de trabajo

No files, tests, or entry points are named. Start with the TPAC 2024 meeting notes and the linked shadow-dom-selection examples, then review related issues #169 and #163. Done would require resolving the flat-versus-composed tree questions, including API behavior and discontiguous ranges, rather than making an isolated edit.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

This surfaced from the conversation at TPAC 2024 about whether we should use a Flat Tree Traversal (Meeting notes) for comparing Selection positions that cross shadow trees.

Composed Tree

With the Composed Tree, we do the normal DOM tree traversal, but consider the owner document to be the common ancestor.
Why this is good:

  • Currently, most Selection API uses the Composed Tree, including setStart/setEnd/setBaseAndExtent/isPointInRange. There might be many compat risks to change these APIs.
  • Doesn’t require updating Style and Layout. Easier to implement.

Flat Tree

With the Flat Tree, we traverse a flattened tree where the shadow trees are flattened to all be contained within one tree.
Why this is good:

  • This is what the user sees when the selection is painted.
  • Would take care of re-ordered slotted contents.
  • Would make IsPointInRange() and toString() more useful to web users, as what the user sees is what’s selected in the flat tree.
  • It avoids the problem of multiple range objects to manage, but looks visually contiguous to the user

Open questions

  1. Should we change existing Selection APIs to use flat trees? This information can be stored internally and only be accessed by getComposedRanges(), keeping the rest of the behaviors unchanged.
  2. Else, should we have new APIs which definitely do use Flat Tree?
  3. Should we support discontiguous ranges?

Examples:

Selection where start and end are in the same tree, but slotted to be in reverse order.
Selection start from the sibling of shadow host, end inside the slotted content.
https://github.com/mfreed7/shadow-dom-selection?tab=readme-ov-file#3-slotted-content

Some use cases

Bidi, tables, flex/grid layout maybe.

Related issues

Need spec changes to Range and StaticRange to support nodes in different tree? #169
Serialization of the current selection, when that selection crosses shadow roots #163

Lenguaje dominante
HTML
Estrellas
49
Forks
30
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de w3c/selection-api

Todos los issues de w3c/selection-api

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.