Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp b/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp |
| index 3a86b11717625760f3789adeb987a9e283a7ca37..245325346259c147220ee08b42f6645a05583b4a 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLTableRowElement.cpp |
| @@ -114,17 +114,25 @@ void HTMLTableRowElement::deleteCell(int index, |
| ExceptionState& exceptionState) { |
| HTMLCollection* children = cells(); |
| int numCells = children ? children->length() : 0; |
| - if (index == -1) |
| - index = numCells - 1; |
| - if (index >= 0 && index < numCells) { |
| - Element* cell = children->item(index); |
| - HTMLElement::removeChild(cell, exceptionState); |
| - } else { |
| + // 1. If index is less than −1 or greater than the number of |
| + // elements in the cells collection, then throw "IndexSizeError". |
|
foolip
2016/10/12 14:19:01
Oh look, the spec has a bug here, doesn't it? I co
rwlbuis
2016/10/12 15:29:39
I added myself and okayed the change.
|
| + if (index < -1 || index >= numCells) { |
| exceptionState.throwDOMException( |
| IndexSizeError, "The value provided (" + String::number(index) + |
| ") is outside the range [0, " + |
| String::number(numCells) + ")."); |
| + return; |
| + } |
| + // 2. If index is −1, remove the last element in the cells collection |
| + // from its parent, or do nothing if the cells collection is empty. |
| + if (index == -1) { |
| + if (numCells == 0) |
| + return; |
| + index = numCells - 1; |
| } |
| + // 3. Remove the indexth element in the cells collection from its parent. |
| + Element* cell = children->item(index); |
| + HTMLElement::removeChild(cell, exceptionState); |
| } |
| HTMLCollection* HTMLTableRowElement::cells() { |