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

未关闭
#30,752 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
领域
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 小时
30 天内合并 PR
86

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/ionic-framework 的其他 Issue

查看 ionic-team/ionic-framework 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。