Skip to content

Fragment serialization algorithm serializes node itself #28

Open

Description

@bwrrp

If implemented as specified, the "fragment serialization algorithm" described in this specification, when given node in an XML document, simply returns "an XML serialization of node passing the flag require well-formed". This means that innerHTML would actually return the outerHTML of the element, and outerHTML would need to return the serialization of a fictional node, for which no further details are given.

It looks like, in order to match the intended behavior, the fragment serialization algorithm should return the concatenation of producing the XML serializations for each of node's children, in tree order. This behavior matches the algorithm described in the HTML spec.

I'd love to send a PR, but there are some options regarding how much of the serialization algorithm's state to propagate between the children. In particular, the generated prefix index could either be propagated from serializing one child to the next, or reset to 1 for each child. Each serialization would be equally valid.

Activity

  1. domenic commented on Oct 22, 2018

    @domenic
    Collaborator

    @Sebmaster, I believe you ran into this when implementing https://github.com/jsdom/w3c-xmlserializer . Do you agree with the OP / what was your fix?

  2. Sebmaster commented on Oct 22, 2018

    @Sebmaster

    That is correct, we're doing serialization of children, resetting generatedPrefixIndex to 1 for each child (since we can still implement the algorithm as described and just have to modify the caller slightly).

  3. cscott commented on Jul 1, 2021

    @cscott

    Ran into this just now, trying to implement innerHTML for a PHP DOM implementation. It would be nice to get the spec fixed in order to clarify the generatedPrefix issues (at least).

  4. domenic commented on Jul 1, 2021

    @domenic
    Collaborator

    PRs welcome; I think I still have review rights at least.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions