Skip to content

Browsers don't agree on mutation records for .append(documentFragment) #1509

Open

Description

@Jamesernator

What is the issue with the DOM Standard?

I'm not sure how much flexibility implementations are meant to have regarding emitting different mutation records, but basically the following code has different results in Chrome/Firefox compared to Webkit (tested on Epiphany):

const parent = document.createElement("div");
const fragment = new DocumentFragment();
fragment.append(document.createElement("foo"), document.createElement("bar"));

const observer = new MutationObserver(console.log);
observer.observe(fragment, { childList: true });

parent.append(fragment);
    
console.log(observer.takeRecords());

In Chrome/Firefox this prints a single mutation record with both elements in removedNodes, but in Webkit this produces two mutation records with removedNodes containing a single element in each record.

Is this something implementations should align on? Or are implementations expected to have flexibility with regards to the exact batching of their mutation records. (I noticed this because I'm implementing a pure JS implementation of just the DOM spec + the HTML parsing methods, and noticed these records didn't match all browsers).

Activity

  1. changed the title [-]Browsers don't agree on mutation records for .append(documentFragment) (and friends)[/-] [+]Browsers don't agree on mutation records for .append(documentFragment)[/+] on Oct 8, 2026
  2. annevk commented on Oct 8, 2026

    @annevk
    Member

    The specification is precise and this a WebKit bug. If not covered on WPT we should add tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions