From d1856b17d1b9a5ffba63ad7930a2e1e32fefbc49 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Mon, 5 Feb 2018 15:20:32 +0100 Subject: [PATCH 1/2] Editorial: call out inconsistency in document.body behavior Fixes #3403. Tests: https://github.com/w3c/web-platform-tests/pull/9231 --- source | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source b/source index 5832f71b7e5..18220431aed 100644 --- a/source +++ b/source @@ -9606,6 +9606,9 @@ partial interface Document { +

The body attribute has different behavior + on getting and setting when used for a non-HTML document, or in certain edge cases.

+
From 366b025664f047491b098843d57640dca1d61cf5 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Mon, 12 Feb 2018 10:28:56 +0100 Subject: [PATCH 2/2] Reword note and add an example --- source | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source b/source index 18220431aed..6ca71210ef7 100644 --- a/source +++ b/source @@ -9606,8 +9606,22 @@ partial interface Document { -

The body attribute has different behavior - on getting and setting when used for a non-HTML document, or in certain edge cases.

+

The value returned by the body getter is + not always the one passed to the setter.

+ +
+

In this example, the setter successfully inserts a body element (though this is + non-conforming since SVG does not allow a body as child of SVG + svg). However the getter will return null because the document element is not + html.

+ +
<svg xmlns="http://www.w3.org/2000/svg">
+ <script>
+  document.body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
+  console.assert(document.body === null);
+ </script>
+</svg>
+