mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Removed JS::root Fixes #8251
This commit is contained in:
parent
521a87180a
commit
d8ef3809a6
25 changed files with 98 additions and 126 deletions
|
@ -874,16 +874,15 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn get_attribute(&self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
|
||||
self.attrs.borrow().iter().map(JS::root).find(|attr| {
|
||||
self.attrs.borrow().iter().find(|attr| {
|
||||
attr.local_name() == local_name && attr.namespace() == namespace
|
||||
})
|
||||
}).map(|js| Root::from_ref(&**js))
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<Root<Attr>> {
|
||||
let name = &self.parsed_name(name);
|
||||
self.attrs.borrow().iter().map(JS::root)
|
||||
.find(|a| a.r().name() == name)
|
||||
self.attrs.borrow().iter().find(|a| a.name() == name).map(|js| Root::from_ref(&**js))
|
||||
}
|
||||
|
||||
pub fn set_attribute_from_parser(&self,
|
||||
|
@ -891,8 +890,8 @@ impl Element {
|
|||
value: DOMString,
|
||||
prefix: Option<Atom>) {
|
||||
// Don't set if the attribute already exists, so we can handle add_attrs_if_missing
|
||||
if self.attrs.borrow().iter().map(JS::root)
|
||||
.any(|a| *a.r().local_name() == qname.local && *a.r().namespace() == qname.ns) {
|
||||
if self.attrs.borrow().iter()
|
||||
.any(|a| *a.local_name() == qname.local && *a.namespace() == qname.ns) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -942,7 +941,8 @@ impl Element {
|
|||
find: F)
|
||||
where F: Fn(&Attr)
|
||||
-> bool {
|
||||
let attr = self.attrs.borrow().iter().map(JS::root).find(|attr| find(&attr));
|
||||
let attr = self.attrs.borrow().iter()
|
||||
.find(|attr| find(&attr)).map(|js| Root::from_ref(&**js));
|
||||
if let Some(attr) = attr {
|
||||
attr.set_value(value, self);
|
||||
} else {
|
||||
|
@ -973,10 +973,10 @@ impl Element {
|
|||
fn remove_first_matching_attribute<F>(&self, find: F) -> Option<Root<Attr>>
|
||||
where F: Fn(&Attr) -> bool
|
||||
{
|
||||
let idx = self.attrs.borrow().iter().map(JS::root).position(|attr| find(&attr));
|
||||
let idx = self.attrs.borrow().iter().position(|attr| find(&attr));
|
||||
|
||||
idx.map(|idx| {
|
||||
let attr = (*self.attrs.borrow())[idx].root();
|
||||
let attr = Root::from_ref(&*(*self.attrs.borrow())[idx]);
|
||||
self.attrs.borrow_mut().remove(idx);
|
||||
attr.set_owner(None);
|
||||
if attr.namespace() == &ns!("") {
|
||||
|
@ -1005,8 +1005,8 @@ impl Element {
|
|||
|
||||
pub fn has_attribute(&self, local_name: &Atom) -> bool {
|
||||
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
|
||||
self.attrs.borrow().iter().map(JS::root).any(|attr| {
|
||||
attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
|
||||
self.attrs.borrow().iter().any(|attr| {
|
||||
attr.local_name() == local_name && attr.namespace() == &ns!("")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1695,8 +1695,8 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
})
|
||||
},
|
||||
NamespaceConstraint::Any => {
|
||||
self.attrs.borrow().iter().map(JS::root).any(|attr| {
|
||||
attr.local_name() == local_name && test(&attr.value())
|
||||
self.attrs.borrow().iter().any(|attr| {
|
||||
attr.local_name() == local_name && test(&attr.value())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue