mirror of
https://github.com/servo/servo.git
synced 2025-08-01 03:30:33 +01:00
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:
parent
026b5e34ea
commit
cdde96e989
2 changed files with 52 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue