| Index: third_party/WebKit/Source/core/dom/Range.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
|
| index fcc24003565722162929fd31f9b2eda301c7b44c..3187a1e9c746f3eef49a70065a484b4e3f5c92da 100644
|
| --- a/third_party/WebKit/Source/core/dom/Range.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Range.cpp
|
| @@ -917,11 +917,15 @@ void Range::insertNode(Node* newNode, ExceptionState& exceptionState) {
|
| }
|
|
|
| container = m_start.container();
|
| - container->insertBefore(
|
| - newNode, NodeTraversal::childAt(*container, m_start.offset()),
|
| - exceptionState);
|
| - if (exceptionState.hadException())
|
| - return;
|
| + Node* referenceNode = NodeTraversal::childAt(*container, m_start.offset());
|
| + // TODO(tkent): The following check must be unnecessary if we follow the
|
| + // algorithm defined in the specification.
|
| + // https://dom.spec.whatwg.org/#concept-range-insert
|
| + if (newNode != referenceNode) {
|
| + container->insertBefore(newNode, referenceNode, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return;
|
| + }
|
|
|
| // Note that m_start.offset() may have changed as a result of
|
| // container->insertBefore, when the node we are inserting comes before the
|
|
|