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], alert 或 banner

取消策略:

  • <dialog> → dialog.close()
  • [popover] → el.hidePopover()
  • .instui-alert or .instui-banner → 可取消的 dismiss 事件,然后淡出并移除
  • [data-dismissible] or [open] → 移除 open 属性 + 触发冒泡 close

参数 ​

btn ​

HTMLElement

返回值 ​

void