Skip to content

pantoken-root / formats/interactions/src / initCloseButton

函式: initCloseButton() ​

initCloseButton(btn): void

將關閉按鈕接線,使其能關閉其目標。

目標解析(以首個符合者為準):

  1. data-close-target="id" — 以該 id 隱藏元素
  2. popovertarget / commandfor — 跳過;由原生瀏覽器處理
  3. 向上查找最近的 <dialog>, [popover], [data-dismissible], [open], 警示或橫幅)

關閉策略:

  • <dialog> → dialog.close()
  • [popover] → el.hidePopover()
  • .instui-alert or .instui-banner → 可取消的 dismiss 事件,然後淡出並移除
  • [data-dismissible] 或 [open] → 移除 open 屬性 + 觸發冒泡 close

參數 ​

btn ​

HTMLElement

回傳 ​

void