#1141·obscura

DOM mutation, MutationObserver, Range and node documents differ from the DOM spec

Author: ice-zeusCreated Oct 1, 2026Updated Oct 1, 2026

DOM mutation, MutationObserver, Range, node document and some CSSOM behavior differs from the DOM and CSSOM specs and from Chromium. A 22-file WPT subset passes 69 of 169 subtests on main (Chromium: 165), and one harness never completes.

Environment: 2f6e09a, release --features render,stealth, WPT 8b6e09b0fe80243092050c92ff430a47c2d30b77, x86_64 Linux.

Main causes, by area:

  • Insertion and removal.
    • insertBefore(null, null) returns silently.
    • Non-Node arguments to removeChild throw NotFoundError instead of TypeError.
    • Document child constraints (one element, one doctype, doctype before element, no text) are not enforced.
    • The order of the pre-insertion checks differs from the spec, so the wrong exception is thrown.
  • MutationObserver records.
    • Records have no previousSibling, nextSibling or attributeNamespace.
    • Inserting a DocumentFragment produces one record per child.
    • Moving a node produces no removal record on its old parent.
    • removeAttribute produces no record.
    • Options are not validated.
  • Range. deleteContents, extractContents, cloneContents and surroundContents are no-ops. Observers waiting on their records never fire, which is the cause of the MutationObserver-childList.html timeout.
  • Node documents. Node.ownerDocument always returns the main document. createHTMLDocument and createDocument return plain objects rather than Document nodes.
  • CSSOM. @media rules are opaque CSSRule objects, so mediaRule.insertRule is not a function. CSSOM rule changes do not invalidate cached computed style.
  • getComputedStyle. It returns real values for detached elements; Chromium returns an empty declaration.
  • IntersectionObserver.
    • The callback's this is not the observer.
    • Entries are plain objects.
    • isIntersecting ignores thresholds.
    • boundingClientRect.left is 15 or 19 instead of 11 in two tests. The cause is in layout: inside an inline-block, block children share a flex row (auto widths collapse to 0), and formatting whitespace around them takes space.

Minimal checks:

javascript
document.body.insertBefore(null, null);            // returns; Chromium throws TypeError
document.implementation.createHTMLDocument("t")
  .createElement("p").ownerDocument === document;  // true; should be the new document
document.createRange().deleteContents;             // runs, removes nothing
getComputedStyle(document.createElement("div")).display;  // "block"; Chromium ""

A pull request with the fixes and tests follows.