Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: Optimize CompareDocumentPosition. #18113

Merged
merged 3 commits into from Aug 17, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

script: Add a function to check whether a node is before another one …

…in DOM order.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
  • Loading branch information
emilio committed Aug 17, 2017
commit f6bfd44ad6b3d1905c1eb59cc00cf4cb499863c8
@@ -385,6 +385,17 @@ impl Node {
}
}

/// Returns true if this node is before `other` in the same connected DOM
/// tree.
pub fn is_before(&self, other: &Node) -> bool {
let cmp = other.CompareDocumentPosition(self);
if cmp & NodeConstants::DOCUMENT_POSITION_DISCONNECTED != 0 {
return false;
}

cmp & NodeConstants::DOCUMENT_POSITION_PRECEDING != 0
}

/// Return all registered mutation observers for this node.
pub fn registered_mutation_observers(&self) -> RefMut<Vec<RegisteredObserver>> {
self.mutation_observers.borrow_mut()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.