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

Đang mở
#30,752 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, typescript
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

Issue không xác định các tệp, bài kiểm thử hoặc điểm vào. Hãy bắt đầu bằng cách tìm các tham chiếu Ionic hiện đang gọi document.getElementById(id), sau đó so sánh hành vi của chúng bên trong một shadow DOM với cách tra cứu được đề xuất là tra cứu cục bộ trước rồi đến document; hoàn thành có nghĩa là các tham chiếu hoạt động trong cả hai phạm vi mà không làm hỏng các tra cứu hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
52.8k
Fork
13.3k
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
86

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ionic-team/ionic-framework

Tất cả issue của ionic-team/ionic-framework

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.