You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fragment serialization algorithm serializes node itself #28
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.
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).
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).
Activity
domenic commentedon Oct 22, 2018
@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?
Sebmaster commentedon Oct 22, 2018
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).
cscott commentedon Jul 1, 2021
Ran into this just now, trying to implement
innerHTMLfor a PHP DOM implementation. It would be nice to get the spec fixed in order to clarify the generatedPrefix issues (at least).domenic commentedon Jul 1, 2021
PRs welcome; I think I still have review rights at least.
Implement ::innerHTML getter, ::outerHTML getter, XMLSerializer