mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
Implement Node.contains
Spec: http://dom.spec.whatwg.org/#dom-node-contains Closes #1647.
This commit is contained in:
parent
9305a95b68
commit
99b3b144d4
4 changed files with 33 additions and 4 deletions
|
@ -323,7 +323,8 @@ DOMInterfaces = {
|
|||
'nodeValue',
|
||||
'removeChild',
|
||||
'textContent',
|
||||
'childNodes'
|
||||
'childNodes',
|
||||
'contains',
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
@ -1538,8 +1538,11 @@ impl Node {
|
|||
0
|
||||
}
|
||||
|
||||
pub fn Contains(&self, _other: Option<AbstractNode>) -> bool {
|
||||
false
|
||||
pub fn Contains(&self, abstract_self: AbstractNode, maybe_other: Option<AbstractNode>) -> bool {
|
||||
match maybe_other {
|
||||
None => false,
|
||||
Some(other) => abstract_self.is_inclusive_ancestor_of(other)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn LookupPrefix(&self, _prefix: Option<DOMString>) -> Option<DOMString> {
|
||||
|
|
|
@ -78,7 +78,7 @@ interface Node : EventTarget {
|
|||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
|
||||
unsigned short compareDocumentPosition(Node other);
|
||||
//boolean contains(Node? other); //XXXjdm we don't deal well with Node? parameters
|
||||
boolean contains(Node? other);
|
||||
|
||||
DOMString? lookupPrefix(DOMString? namespace);
|
||||
DOMString? lookupNamespaceURI(DOMString? prefix);
|
||||
|
|
25
src/test/html/content/test_node_contains.html
Normal file
25
src/test/html/content/test_node_contains.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="harness.js"></script>
|
||||
<script>
|
||||
// test1: Node.contains
|
||||
{
|
||||
var parent = document.createElement("div");
|
||||
var child = document.createElement("div");
|
||||
var child_of_child = document.createElement("div");
|
||||
var other = document.createElement("div");
|
||||
|
||||
child.appendChild(child_of_child);
|
||||
parent.appendChild(child);
|
||||
|
||||
is(parent.contains(parent), true, "test1-0, Node.contains");
|
||||
is(parent.contains(child), true, "test1-1, Node.contains");
|
||||
is(parent.contains(child_of_child), true, "test1-2, Node.contains");
|
||||
is(parent.contains(other), false, "test1-3, Node.contains");
|
||||
}
|
||||
|
||||
finish();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue