From 2d08290117af916d1c3c46d6ababb0f04833a8f2 Mon Sep 17 00:00:00 2001 From: Oriol Date: Fri, 15 Apr 2016 09:01:00 -0400 Subject: [PATCH] Bug 1258205 - Make setAttribute throw InvalidCharacterError if the attribute already exists. r=baku --- dom/base/Element.cpp | 10 ++++------ .../web-platform/meta/dom/nodes/attributes.html.ini | 3 --- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index b2bbba8e5fee..41b97a56189b 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1177,14 +1177,12 @@ Element::SetAttribute(const nsAString& aName, const nsAString& aValue, ErrorResult& aError) { + aError = nsContentUtils::CheckQName(aName, false); + if (aError.Failed()) { + return; + } const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName); - if (!name) { - aError = nsContentUtils::CheckQName(aName, false); - if (aError.Failed()) { - return; - } - nsCOMPtr nameAtom; if (IsHTMLElement() && IsInHTMLDocument()) { nsAutoString lower; diff --git a/testing/web-platform/meta/dom/nodes/attributes.html.ini b/testing/web-platform/meta/dom/nodes/attributes.html.ini index 79bcd8adf5b8..5a49c2cea552 100644 --- a/testing/web-platform/meta/dom/nodes/attributes.html.ini +++ b/testing/web-platform/meta/dom/nodes/attributes.html.ini @@ -6,6 +6,3 @@ [First set attribute is returned with mapped attribute set first] expected: FAIL - [When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown, even if the attribute is already present. (setAttribute)] - expected: FAIL -