From ce285b6f2d48ce945b194fd7982cd6a5a306e939 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Wed, 1 Jan 2020 15:08:37 -0500 Subject: Bug 1276438 part 3. Align the .body setter with the spec a bit better. There are two changes here: 1) We allow setting .body even if the root element is not an . This is what the spec says to do, and what we used to do before the changes in bug 366200. No tests for this yet, pending https://github.com/whatwg/html/issues/3403 getting resolved. 2) We use GetBody(), not GetBodyElement(), to look for an existing thing to replace. This matters if there are s involved. Tag UXP Issue #1344 Tag UXP Issue #252 --- dom/base/nsDocument.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'dom/base') diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 69cbff16c..3faa39ab3 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6562,18 +6562,16 @@ nsIDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv) nsCOMPtr root = GetRootElement(); // The body element must be either a body tag or a frameset tag. And we must - // have a html root tag, otherwise GetBody will not return the newly set - // body. + // have a root element to be able to add kids to it. if (!newBody || !newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) || - !root || !root->IsHTMLElement() || - !root->IsHTMLElement(nsGkAtoms::html)) { + !root) { rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); return; } // Use DOM methods so that we pass through the appropriate security checks. - nsCOMPtr currentBody = GetBodyElement(); + nsCOMPtr currentBody = GetBody(); if (currentBody) { root->ReplaceChild(*newBody, *currentBody, rv); } else { -- cgit v1.2.3