Skip to content

pantoken-root / formats/interactions/src / initCloseButton

Hàm: initCloseButton() ​

initCloseButton(btn): void

Gắn một nút đóng để đóng mục tiêu của nó.

Giải quyết mục tiêu (khớp đầu tiên thắng):

  1. data-close-target="id" — loại bỏ phần tử có id đó
  2. popovertarget / commandfor — bỏ qua; trình duyệt gốc xử lý nó
  3. đi lên tới phần tử gần nhất <dialog>, [popover], [data-dismissible], [open], cảnh báo hoặc banner

Chiến lược đóng:

  • <dialog> → dialog.close()
  • [popover] → el.hidePopover()
  • .instui-alert or .instui-banner → sự kiện có thể hủy dismiss, sau đó mờ dần và loại bỏ
  • [data-dismissible] or [open] → xóa thuộc tính open + phát sự kiện lan truyền close

Tham số ​

btn ​

HTMLElement

Trả về ​

void