Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25734,7 +25734,7 @@ interface MutationObserver {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MutationObserver/observe)
*/
observe(target: Node, options?: MutationObserverInit): void;
observe(target: Node, options: MutationObserverInit): void;
/**
* The MutationObserver method **`takeRecords()`** returns a list of all matching DOM changes that have been detected but not yet processed by the observer's callback function, leaving the mutation queue empty.
*
Expand Down
2 changes: 1 addition & 1 deletion baselines/ts5.5/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25710,7 +25710,7 @@ interface MutationObserver {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MutationObserver/observe)
*/
observe(target: Node, options?: MutationObserverInit): void;
observe(target: Node, options: MutationObserverInit): void;
/**
* The MutationObserver method **`takeRecords()`** returns a list of all matching DOM changes that have been detected but not yet processed by the observer's callback function, leaving the mutation queue empty.
*
Expand Down
2 changes: 1 addition & 1 deletion baselines/ts5.6/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25731,7 +25731,7 @@ interface MutationObserver {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MutationObserver/observe)
*/
observe(target: Node, options?: MutationObserverInit): void;
observe(target: Node, options: MutationObserverInit): void;
/**
* The MutationObserver method **`takeRecords()`** returns a list of all matching DOM changes that have been detected but not yet processed by the observer's callback function, leaving the mutation queue empty.
*
Expand Down
2 changes: 1 addition & 1 deletion baselines/ts5.9/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25731,7 +25731,7 @@ interface MutationObserver {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MutationObserver/observe)
*/
observe(target: Node, options?: MutationObserverInit): void;
observe(target: Node, options: MutationObserverInit): void;
/**
* The MutationObserver method **`takeRecords()`** returns a list of all matching DOM changes that have been detected but not yet processed by the observer's callback function, leaving the mutation queue empty.
*
Expand Down
9 changes: 9 additions & 0 deletions inputfiles/patches/dom.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ interface Document {
}
}

// observe() always throws a TypeError when none of childList, attributes or characterData ends up true,
// so calling it without options can never work. Web IDL can't express that dependency, hence the default {}.
// See https://dom.spec.whatwg.org/#dom-mutationobserver-observe
interface MutationObserver {
method observe signatureIndex=0 {
param options optional=#false
}
}

interface MutationRecord {
property type type=MutationRecordType
}
Expand Down
1 change: 1 addition & 0 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ function handleParam(node: Node) {
name,
...handleTyped(typeNodes, node.properties?.type),
...optionalMember("overrideType", "string", node.properties?.overrideType),
...optionalMember("optional", "boolean", node.properties?.optional),
...(additionalTypes ? { additionalTypes } : {}),
};
}
Expand Down
10 changes: 10 additions & 0 deletions unittests/files/mutationobserver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const observer = new MutationObserver(() => {});

// @ts-expect-error options are required, observe() throws without them
observer.observe(document.body);

observer.observe(document.body, { childList: true });
observer.observe(document.body, { attributeFilter: ["class"] });

declare const options: MutationObserverInit;
observer.observe(document.body, options);
Loading