From d36d3eb0e2164d3bdec168f047f15b7925bd5f83 Mon Sep 17 00:00:00 2001 From: Zirro Date: Wed, 19 Dec 2018 21:52:23 +0100 Subject: [PATCH] Serialize the children of void elements as the empty string Fixes #4220, by making the algorithm consistent with the current implementations in Blink and WebKit, as well as the existing web platform tests. Now, innerHTML of void elements returns the empty string even in cases where child nodes are present. Tests (preexisting): https://wpt.fyi/results/html/syntax/serializing-html-fragments/serializing.html --- source | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/source b/source index 2008a4dab19..0ff2ef91afe 100644 --- a/source +++ b/source @@ -99953,7 +99953,6 @@ dictionary StorageEventInit : EventInit {
area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr
- @@ -110567,6 +110566,10 @@ document.body.appendChild(text);

Serializing HTML fragments

+

For the purposes of the following algorithm, an element serializes as void if its + element type is one of the void elements, or is basefont, + bgsound, frame, or keygen.

+

The following steps form the HTML fragment serialization algorithm. The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as @@ -110577,6 +110580,9 @@ document.body.appendChild(text);

    +
  1. If the node serializes as void, then return the empty + string.

  2. +
  3. Let s be a string, and initialize it to the empty string.

  4. If the node is a template element, then let the node instead be the template element's template @@ -110681,15 +110687,8 @@ document.body.appendChild(text);

    Append a U+003E GREATER-THAN SIGN character (>).

    -

    If current node is an area, base, - basefont, bgsound, br, col, - embed, frame, hr, img, - input, keygen, link, meta, - param, source, track or wbr element, - then continue on to the next child node at this point.

    - - +

    If current node serializes as void, then continue on to the next + child node at this point.

    Append the value of running the HTML fragment serialization algorithm on the current node element (thus recursing into this algorithm for that @@ -110764,7 +110763,7 @@ document.body.appendChild(text);

  5. -
  6. The result of the algorithm is the string s.

  7. +
  8. Return s.