feat: Allow triggers and other references to be used inside shadow DOM of other WebComponent

Abierto
#30,752 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, typescript
Área
frontend, web-dev

Línea de trabajo

El issue no identifica archivos, pruebas ni puntos de entrada. Empieza por localizar las referencias de Ionic que actualmente llaman a document.getElementById(id) y, después, compara su comportamiento dentro de un shadow DOM con la búsqueda local y luego en el documento propuesta; se considera terminado cuando las referencias funcionan en ambos ámbitos sin romper las búsquedas existentes.

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

Descripción

type: feature request
Prerequisites
Describe the Feature Request

Make (Ionic) elements which refer to other (Ionic) elements be usable inside the shadow DOM of some other (non-Ionic) WebComponent.

Describe the Use Case

When using elements which have a reference to some other element (like a trigger or an <ion-datetime-button> referencing an <ion-datetime>) the search for the reference is always performed on the root document. I use these elements inside a shadow DOM of some other WebComponent. I would like these references to be searched within the shadow DOM first and if failing, be performed on the root document.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

Code wise this could probably be implemented without influencing existing code (except if you have the same identifier in your shadow DOM and your document root, but wondering if such a situation would be logical or only theoretical):
Every reference is searched using document.getElementById(id). If all these occurrences are replaced by a call to the following function getReferencedElement(this, id), it would try the local reference first.

function getReferencedElement(element, id) {
    // Start searching within the elements shadow DOM or from document root
    let rootNode = element.getRootNode();
    let referencedElement = rootNode.getElementById(id);
    if(referencedElement) {
        return referencedElement;
    }
    // In case searched in shadow DOM (but did not find anything), search document root
    if(rootNode !== document) {
        return document.getElementById(id);
    }
    return null;
}

Above code is untested and meant to describe a general solution.

Additional Information

I'm happy to create a PR if this feature would be accepted for incorporation.

Lenguaje dominante
TypeScript
Estrellas
52.8k
Forks
13.3k
Merge medio
3 d 1 h
PR fusionados (30 d)
86

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 ionic-team/ionic-framework

Todos los issues de ionic-team/ionic-framework

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.