Microsoft/TypeScript

Update lib.dom.d.ts: `MutationObserverInit.attributeFilter` can accept an iterator

Open

#55,990 建立於 2023年10月5日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

⚙ Compilation target

n/a

⚙ Library

lib.dom

Missing / Incorrect Definition

MutationObserverInit

Sample Code

The following code works in Chredge, Firefox, and Safari:

const obs = new MutationObserver((records) => {
    console.log(...records)
})

const s = new Set(['foo', 'bar'])

obs.observe(document.body, {
  attributeFilter: s.keys() // <--------- HERE
})

document.body.setAttribute('foo', 'foo')
document.body.removeAttribute('foo')
document.body.setAttribute('bar', 'bar')
document.body.removeAttribute('bar')

Edge screenshot:

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#parameters

WIP Pull Request

貢獻者指南