Index: Source/core/dom/ContainerNode.cpp |
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
index 1f9886e28c02eb1ca33f1ed329975120d9ad47ce..1b79bd9c1c742bc7b2726f9fb32ab007f6b58a4a 100644 |
--- a/Source/core/dom/ContainerNode.cpp |
+++ b/Source/core/dom/ContainerNode.cpp |
@@ -145,26 +145,18 @@ bool ContainerNode::checkAcceptChild(const Node* newChild, const Node* oldChild, |
return false; |
} |
- if (containsConsideringHostElements(*newChild)) { |
- exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent."); |
- return false; |
- } |
+ return checkAcceptChildGuaranteedNodeTypes(*newChild, oldChild, exceptionState); |
+} |
+bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, const Node* oldChild, ExceptionState& exceptionState) const |
+{ |
if (isDocumentNode()) |
- return toDocument(this)->canAcceptChild(*newChild, oldChild, exceptionState); |
- |
- if (!isChildTypeAllowed(*newChild)) { |
- exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'."); |
+ return toDocument(this)->canAcceptChild(newChild, oldChild, exceptionState); |
+ if (!isChildTypeAllowed(newChild)) { |
+ exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '" + newChild.nodeName() + "' may not be inserted inside nodes of type '" + nodeName() + "'."); |
return false; |
} |
- |
- return true; |
-} |
- |
-bool ContainerNode::checkAcceptChildGuaranteedNodeTypes(const Node& newChild, ExceptionState& exceptionState) const |
-{ |
- ASSERT(isChildTypeAllowed(newChild)); |
- if (newChild.contains(this)) { |
+ if (newChild.containsIncludingHostElements(*this)) { |
exceptionState.throwDOMException(HierarchyRequestError, "The new child element contains the parent."); |
return false; |
} |
@@ -214,7 +206,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr< |
return newChild; |
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events. |
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) { |
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)) { |
if (exceptionState.hadException()) |
return nullptr; |
return newChild; |
@@ -737,7 +729,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::appendChild(PassRefPtrWillBeRawPtr<N |
return newChild; |
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events. |
- if (!checkAcceptChildGuaranteedNodeTypes(*newChild, exceptionState)) { |
+ if (!checkAcceptChildGuaranteedNodeTypes(*newChild, nullptr, exceptionState)) { |
if (exceptionState.hadException()) |
return nullptr; |
return newChild; |