Skip to content

Update lib.dom.d.ts: MutationObserverInit.attributeFilter can accept an iterator - #64332

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 2 commits into
mainfrom
copilot/update-mutationobserverinit-definition
Draft

Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 2 commits into
mainfrom
copilot/update-mutationobserverinit-definition

Conversation

Copilot AI commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

MutationObserverInit.attributeFilter was typed as string[], but the DOM spec models it as sequence<DOMString>, whose WebIDL conversion accepts any iterable. Browsers (Chromium, Firefox, Safari) accept iterables like Set<string>.keys(), but TypeScript rejected them with TS2740.

Type change

  • Widened MutationObserverInit.attributeFilter from string[] to string[] | Iterable<string> in lib.dom.d.ts
const names = new Set<string>(["foo", "bar"]);

observer.observe(document.body, {
  attributeFilter: names.keys(), // now valid
});

Tests

  • Added a compiler test covering array, iterator, and Set inputs for attributeFilter

@typescript-automation typescript-automation Bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Sep 19, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 19, 2026
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Update lib.dom.d.ts to support iterator for attributeFilter Update lib.dom.d.ts: MutationObserverInit.attributeFilter can accept an iterator Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants