mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
parent
10a0f984c3
commit
78eeb8e2e7
4 changed files with 0 additions and 51 deletions
|
@ -451,7 +451,6 @@ pub trait ElementMethods {
|
||||||
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
|
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
|
||||||
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
||||||
fn Remove(&self);
|
fn Remove(&self);
|
||||||
fn Matches(&self, selectors: DOMString) -> Fallible<bool>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ElementMethods for JSRef<'a, Element> {
|
impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
|
@ -758,12 +757,6 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.remove_self();
|
node.remove_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-matches
|
|
||||||
fn Matches(&self, selectors: DOMString) -> Fallible<bool> {
|
|
||||||
let root: &JSRef<Node> = NodeCast::from_ref(self);
|
|
||||||
root.matches(selectors)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_attribute_parts(name: DOMString) -> (Option<String>, String) {
|
pub fn get_attribute_parts(name: DOMString) -> (Option<String>, String) {
|
||||||
|
|
|
@ -396,7 +396,6 @@ pub trait NodeHelpers {
|
||||||
fn query_selector_all(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
fn query_selector_all(&self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
|
||||||
|
|
||||||
fn remove_self(&self);
|
fn remove_self(&self);
|
||||||
fn matches(&self, selectors: DOMString) -> Fallible<bool>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeHelpers for JSRef<'a, Node> {
|
impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
|
@ -649,28 +648,6 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-matches
|
|
||||||
fn matches(&self, selectors: DOMString) -> Fallible<bool> {
|
|
||||||
assert!(self.is_element());
|
|
||||||
// Step 1.
|
|
||||||
let namespace = NamespaceMap::new();
|
|
||||||
match parse_selector_list(tokenize(selectors.as_slice()).map(|(token, _)| token).collect(), &namespace) {
|
|
||||||
// Step 2.
|
|
||||||
None => return Err(Syntax),
|
|
||||||
// Step 3.
|
|
||||||
Some(ref selectors) => {
|
|
||||||
for selector in selectors.iter() {
|
|
||||||
assert!(selector.pseudo_element.is_none());
|
|
||||||
let mut _shareable: bool = false;
|
|
||||||
if matches_compound_selector(selector.compound_selectors.deref(), self, &mut _shareable) {
|
|
||||||
return Ok(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the given untrusted node address represents a valid DOM node in the given runtime,
|
/// If the given untrusted node address represents a valid DOM node in the given runtime,
|
||||||
|
|
|
@ -46,9 +46,6 @@ interface Element : Node {
|
||||||
boolean hasAttribute(DOMString name);
|
boolean hasAttribute(DOMString name);
|
||||||
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
|
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
|
|
||||||
[Throws]
|
|
||||||
boolean matches(DOMString selectors);
|
|
||||||
|
|
||||||
HTMLCollection getElementsByTagName(DOMString localName);
|
HTMLCollection getElementsByTagName(DOMString localName);
|
||||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<script src="harness.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="foo"></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
let test = document.getElementById("foo");
|
|
||||||
|
|
||||||
is(test.matches("#foo"), true, "test-1");
|
|
||||||
is(test.matches("#not-foo"), false, "test-2");
|
|
||||||
|
|
||||||
finish();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Add table
Add a link
Reference in a new issue