aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-11-04 17:23:18 +0100
committerMs2ger <ms2ger@gmail.com>2014-11-05 16:05:06 +0100
commitcdde96e989dc453296acedb598b2cdb6a18b8da5 (patch)
treebe9887b2c10392e25c4ff0a21df2df689f0b7070
parent026b5e34eaabc572858f1c7de668eacb4ab84c3f (diff)
downloadservo-cdde96e989dc453296acedb598b2cdb6a18b8da5.tar.gz
servo-cdde96e989dc453296acedb598b2cdb6a18b8da5.zip
Defer to GetAttribute in HasAttribute.
The semantics of has_attribute aren't anywhere close to the ones expected for Element#hasAttribute, and it fails an assertion when passed non-lower-case names.
-rw-r--r--components/script/dom/element.rs11
-rw-r--r--tests/wpt/metadata/dom/nodes/attributes.html.ini52
2 files changed, 52 insertions, 11 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a81c515aef8..b317974569e 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -854,16 +854,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
// http://dom.spec.whatwg.org/#dom-element-hasattribute
fn HasAttribute(self, name: DOMString) -> bool {
- // Step 1.
- if self.html_element_in_html_document() {
- // TODO(pcwalton): Small string optimization here.
- return self.has_attribute(&Atom::from_slice(name.as_slice()
- .to_ascii_lower()
- .as_slice()))
- }
-
- // Step 2.
- self.has_attribute(&Atom::from_slice(name.as_slice()))
+ self.GetAttribute(name).is_some()
}
// http://dom.spec.whatwg.org/#dom-element-hasattributens
diff --git a/tests/wpt/metadata/dom/nodes/attributes.html.ini b/tests/wpt/metadata/dom/nodes/attributes.html.ini
index 0d2fc27b53c..78a802084e5 100644
--- a/tests/wpt/metadata/dom/nodes/attributes.html.ini
+++ b/tests/wpt/metadata/dom/nodes/attributes.html.ini
@@ -1,3 +1,53 @@
[attributes.html]
type: testharness
- expected: CRASH
+ [setAttribute should not change the order of previously set attributes.]
+ expected: FAIL
+
+ [setAttribute should set the first attribute with the given name]
+ expected: FAIL
+
+ [setAttribute should set the attribute with the given qualified name]
+ expected: FAIL
+
+ [When qualifiedName does not match the QName production, an NAMESPACE_ERR exception is to be thrown.]
+ expected: FAIL
+
+ [null and the empty string should result in a null namespace.]
+ expected: FAIL
+
+ [XML-namespaced attributes don\'t need an xml prefix]
+ expected: FAIL
+
+ [xmlns should be allowed as local name]
+ expected: FAIL
+
+ [xmlns should be allowed as prefix in the XMLNS namespace]
+ expected: FAIL
+
+ [xmlns should be allowed as qualified name in the XMLNS namespace]
+ expected: FAIL
+
+ [Setting the same attribute with another prefix should not change the prefix]
+ expected: FAIL
+
+ [Attributes should work in document fragments.]
+ expected: FAIL
+
+ [Attribute values should not be parsed.]
+ expected: FAIL
+
+ [Specified attributes should be accessible.]
+ expected: FAIL
+
+ [Entities in attributes should have been expanded while parsing.]
+ expected: FAIL
+
+ [First set attribute is returned by getAttribute]
+ expected: FAIL
+
+ [First set attribute is returned with mapped attribute set later]
+ expected: FAIL
+
+ [Attribute with prefix in local name]
+ expected: FAIL
+