Bug 1258205 - "setAttribute doesn't throw InvalidCharacterError if the attribute already exists". r=amarchesini
☠☠ backed out by 8de93854b963 ☠ ☠
authorOriol <oriol-bugzilla@hotmail.com>
Wed, 13 Apr 2016 09:10:00 +0200
changeset 331207 cd9ea65ce9b992abcd93782fa6932620c19184a8
parent 331206 562eed2171c9f6d84f9ef8eea990c283c6b6dcea
child 331208 b26d5448b54c615588fec7e9f2142ecbf7360253
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersamarchesini
bugs1258205
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1258205 - "setAttribute doesn't throw InvalidCharacterError if the attribute already exists". r=amarchesini
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1172,24 +1172,22 @@ Element::GetAttribute(const nsAString& a
   }
 }
 
 void
 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<nsIAtom> nameAtom;
     if (IsHTMLElement() && IsInHTMLDocument()) {
       nsAutoString lower;
       nsContentUtils::ASCIIToLower(aName, lower);
       nameAtom = NS_Atomize(lower);
     }
     else {
       nameAtom = NS_Atomize(aName);