mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Fix #1264: support namespaced attribute selectors.
This commit is contained in:
parent
4b3defb282
commit
b290823f4d
10 changed files with 27 additions and 29 deletions
|
@ -296,7 +296,7 @@ impl Document {
|
|||
|
||||
pub fn GetElementsByName(&self, name: DOMString) -> @mut HTMLCollection {
|
||||
self.createHTMLCollection(|elem|
|
||||
elem.get_attr("name").is_some() && eq_slice(elem.get_attr("name").unwrap(), name))
|
||||
elem.get_attr(None, "name").is_some() && eq_slice(elem.get_attr(None, "name").unwrap(), name))
|
||||
}
|
||||
|
||||
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
|
||||
|
@ -374,7 +374,7 @@ fn foreach_ided_elements(root: &AbstractNode<ScriptView>,
|
|||
}
|
||||
|
||||
do node.with_imm_element |element| {
|
||||
match element.get_attr("id") {
|
||||
match element.get_attr(None, "id") {
|
||||
Some(id) => {
|
||||
callback(&id.to_str(), &node);
|
||||
}
|
||||
|
|
|
@ -133,8 +133,8 @@ impl ElementLike for Element {
|
|||
self.namespace.to_str().unwrap_or("")
|
||||
}
|
||||
|
||||
fn get_attr(&self, name: &str) -> Option<~str> {
|
||||
self.get_attribute(None, name).map(|attr| attr.value.clone())
|
||||
fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
|
||||
self.get_attribute(ns_url, name).map(|attr| attr.value.clone())
|
||||
}
|
||||
|
||||
fn get_link(&self) -> Option<~str>{
|
||||
|
@ -144,7 +144,7 @@ impl ElementLike for Element {
|
|||
ElementNodeTypeId(HTMLAnchorElementTypeId) |
|
||||
ElementNodeTypeId(HTMLAreaElementTypeId) |
|
||||
ElementNodeTypeId(HTMLLinkElementTypeId)
|
||||
=> self.get_attr("href"),
|
||||
=> self.get_attr(None, "href"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn Id(&self, _abstract_self: AbstractNode<ScriptView>) -> DOMString {
|
||||
match self.get_attr(&"id") {
|
||||
match self.get_attr(None, "id") {
|
||||
Some(x) => x,
|
||||
None => ~""
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||
self.get_attr(name).map(|s| s.to_owned())
|
||||
self.get_attr(None, name).map(|s| s.to_owned())
|
||||
}
|
||||
|
||||
pub fn GetAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Option<DOMString> {
|
||||
|
|
|
@ -58,7 +58,7 @@ impl HTMLDocument {
|
|||
pub fn Links(&self) -> @mut HTMLCollection {
|
||||
self.parent.createHTMLCollection(|elem|
|
||||
(eq_slice(elem.tag_name, "a") || eq_slice(elem.tag_name, "area"))
|
||||
&& elem.get_attr("href").is_some())
|
||||
&& elem.get_attr(None, "href").is_some())
|
||||
}
|
||||
|
||||
pub fn Forms(&self) -> @mut HTMLCollection {
|
||||
|
@ -71,7 +71,7 @@ impl HTMLDocument {
|
|||
|
||||
pub fn Anchors(&self) -> @mut HTMLCollection {
|
||||
self.parent.createHTMLCollection(|elem|
|
||||
eq_slice(elem.tag_name, "a") && elem.get_attr("name").is_some())
|
||||
eq_slice(elem.tag_name, "a") && elem.get_attr(None, "name").is_some())
|
||||
}
|
||||
|
||||
pub fn Applets(&self) -> @mut HTMLCollection {
|
||||
|
|
|
@ -40,7 +40,7 @@ impl HTMLImageElement {
|
|||
/// prefetching the image. This method must be called after `src` is changed.
|
||||
pub fn update_image(&mut self, image_cache: ImageCacheTask, url: Option<Url>) {
|
||||
let elem = &mut self.htmlelement.element;
|
||||
let src_opt = elem.get_attr("src").map(|x| x.to_str());
|
||||
let src_opt = elem.get_attr(None, "src").map(|x| x.to_str());
|
||||
match src_opt {
|
||||
None => {}
|
||||
Some(src) => {
|
||||
|
|
|
@ -29,7 +29,7 @@ impl HTMLScriptElement {
|
|||
|
||||
impl HTMLScriptElement {
|
||||
pub fn Src(&self) -> DOMString {
|
||||
match self.htmlelement.element.get_attr("src") {
|
||||
match self.htmlelement.element.get_attr(None, "src") {
|
||||
Some(s) => s.to_owned(),
|
||||
None => ~""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue