mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
HTMLCollection::create returns live collections by default
This commit is contained in:
parent
a7f8d754d2
commit
3a8a0927e2
4 changed files with 13 additions and 26 deletions
|
@ -450,7 +450,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~ImagesFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Embeds(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -462,7 +462,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~EmbedsFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Plugins(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -480,7 +480,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~LinksFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Forms(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -492,7 +492,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~FormsFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Scripts(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -504,7 +504,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~ScriptsFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Anchors(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -516,7 +516,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~AnchorsFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn Applets(&self, abstract_self: &JS<Document>) -> JS<HTMLCollection> {
|
||||
|
@ -528,7 +528,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
let filter = ~AppletsFilter;
|
||||
HTMLCollection::create_live(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter)
|
||||
}
|
||||
|
||||
pub fn create_collection<T>(&self, callback: |elem: &JS<Node>| -> Option<JS<T>>) -> ~[JS<T>] {
|
||||
|
|
|
@ -51,23 +51,10 @@ impl HTMLCollection {
|
|||
}
|
||||
|
||||
impl HTMLCollection {
|
||||
pub fn create_live(window: &JS<Window>, root: &JS<Node>, filter: ~CollectionFilter) -> JS<HTMLCollection> {
|
||||
pub fn create(window: &JS<Window>, root: &JS<Node>, filter: ~CollectionFilter) -> JS<HTMLCollection> {
|
||||
HTMLCollection::new(window, Live(root.clone(), filter))
|
||||
}
|
||||
|
||||
pub fn create(window: &JS<Window>, root: &JS<Node>, predicate: |elem: &JS<Element>| -> bool) -> JS<HTMLCollection> {
|
||||
let mut elements = ~[];
|
||||
for child in root.traverse_preorder() {
|
||||
if child.is_element() {
|
||||
let elem: JS<Element> = ElementCast::to(&child).unwrap();
|
||||
if predicate(&elem) {
|
||||
elements.push(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
HTMLCollection::new(window, Static(elements))
|
||||
}
|
||||
|
||||
pub fn by_tag_name(window: &JS<Window>, root: &JS<Node>, tag: DOMString)
|
||||
-> JS<HTMLCollection> {
|
||||
struct TagNameFilter {
|
||||
|
@ -81,7 +68,7 @@ impl HTMLCollection {
|
|||
let filter = TagNameFilter {
|
||||
tag: tag
|
||||
};
|
||||
HTMLCollection::create_live(window, root, ~filter)
|
||||
HTMLCollection::create(window, root, ~filter)
|
||||
}
|
||||
|
||||
pub fn by_tag_name_ns(window: &JS<Window>, root: &JS<Node>, tag: DOMString,
|
||||
|
@ -99,7 +86,7 @@ impl HTMLCollection {
|
|||
tag: tag,
|
||||
namespace: namespace
|
||||
};
|
||||
HTMLCollection::create_live(window, root, ~filter)
|
||||
HTMLCollection::create(window, root, ~filter)
|
||||
}
|
||||
|
||||
pub fn by_class_name(window: &JS<Window>, root: &JS<Node>, classes: DOMString)
|
||||
|
@ -115,7 +102,7 @@ impl HTMLCollection {
|
|||
let filter = ClassNameFilter {
|
||||
classes: classes.split(' ').map(|class| class.into_owned()).to_owned_vec()
|
||||
};
|
||||
HTMLCollection::create_live(window, root, ~filter)
|
||||
HTMLCollection::create(window, root, ~filter)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,6 @@ impl HTMLDataListElement {
|
|||
}
|
||||
let node: JS<Node> = NodeCast::from(abstract_self);
|
||||
let filter = ~HTMLDataListOptionsFilter;
|
||||
HTMLCollection::create_live(&window_from_node(&node), &node, filter)
|
||||
HTMLCollection::create(&window_from_node(&node), &node, filter)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ impl HTMLFieldSetElement {
|
|||
}
|
||||
let node: JS<Node> = NodeCast::from(abstract_self);
|
||||
let filter = ~ElementsFilter;
|
||||
HTMLCollection::create_live(&window_from_node(&node), &node, ~filter)
|
||||
HTMLCollection::create(&window_from_node(&node), &node, filter)
|
||||
}
|
||||
|
||||
pub fn WillValidate(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue