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

Define `Selection.rangeCount` when an input field is focused

Abierto
#166 3 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
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
html
Área
web-dev

Línea de trabajo

Start with the two reduced HTML/JavaScript test cases in issue #166 and compare their rangeCount results when focus moves into an input. Read the related Selection API issue #83 and the reported browser behavior; done means the specification clearly defines the expected rangeCount behavior and captures the relevant cases.

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

Descripción

Hello!

In the process of investigating a web compat issue in WebKit that affects Quip's editor, I stumbled into the fact that Selection.rangeCount behaves differently across FF, Chrome and Safari when the selection is moved into a text field.

Consider the following reduced test case:

<input />
<script>
document.querySelector("input").focus();
document.write(`rangeCount := ${getSelection().rangeCount}`);
</script>

Safari 16 and Chrome will show a rangeCount of 1. However, Safari 17 (with Live Range Selection enabled, at time of writing) and Firefox both show a rangeCount of 0. However, if I adjust the test case to additionally set the DOM selection prior to focusing the input:

<input />
<script>
getSelection().setPosition(document.body, 0);
document.querySelector("input").focus();
document.write(`rangeCount := ${getSelection().rangeCount}`);
</script>

...then Firefox outputs 1 instead of 0. The behavior in Firefox seems to be that moving focus into an input field doesn't affect selection ranges, whereas behavior in Safari 16 and Chrome is that the selection will move to the start of the containing shadow host (in this case, the input element). In Safari 17, with Live Range Selection enabled, we'll now expose a rangeCount of 0 after moving focus into a text field.

Edit: this is essentially a small piece of https://github.com/w3c/selection-api/issues/83, that's just about the rangeCount.

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 Web Dev

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.