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.
This commit is contained in:
Ms2ger 2014-11-04 17:23:18 +01:00
parent 026b5e34ea
commit cdde96e989
2 changed files with 52 additions and 11 deletions

View file

@ -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