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

オープン
#30,752 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, typescript
領域
frontend, web-dev

調査の方向性

この issue では、ファイル、テスト、エントリポイントが特定されていません。まず、現在 document.getElementById(id) を呼び出している Ionic の参照を見つけ、次に、shadow DOM 内での動作を、提案されているローカル検索後に document を検索する動作と比較してください。既存の検索を壊さずに、両方のスコープで参照が機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
52.8k
フォーク
13.3k
平均マージ
3日 1時間
マージ済み PR(30日)
86

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ionic-team/ionic-framework のほかの issue

ionic-team/ionic-framework の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。