mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
parent
f7bfea5879
commit
4c5bebeb10
3 changed files with 97 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
use dom::attr::{Attr, AttrHelpers};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||
|
@ -2278,9 +2279,27 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-lookupprefix
|
||||
fn LookupPrefix(self, _prefix: Option<DOMString>) -> Option<DOMString> {
|
||||
// FIXME (#1826) implement.
|
||||
None
|
||||
fn LookupPrefix(self, namespace: Option<DOMString>) -> Option<DOMString> {
|
||||
// Step 1.
|
||||
if null_str_as_empty(&namespace).is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
match self.type_id() {
|
||||
NodeTypeId::Element(..) => ElementCast::to_ref(self).unwrap().lookup_prefix(namespace),
|
||||
NodeTypeId::Document => {
|
||||
DocumentCast::to_ref(self).unwrap().GetDocumentElement().and_then(|element| {
|
||||
element.root().r().lookup_prefix(namespace)
|
||||
})
|
||||
},
|
||||
NodeTypeId::DocumentType | NodeTypeId::DocumentFragment => None,
|
||||
_ => {
|
||||
self.GetParentElement().and_then(|element| {
|
||||
element.root().r().lookup_prefix(namespace)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
|
||||
|
@ -2517,4 +2536,3 @@ pub enum NodeDamage {
|
|||
/// Other parts of a node changed; attributes, text content, etc.
|
||||
OtherNodeDamage,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue