8000 Support matchesSelector and the like · Issue #114 · fat/bean · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support matchesSelector and the like #114
Open
@fabiosantoscode

Description

@fabiosantoscode

When trying to find an element which matches a delegation selector, the findTarget function must select every element which matches the selector (potentially expensive), and loop that selection for each depth level in the DOM tree. It could get pretty suboptimal when the matched selection is large.

The most optimal way would be to go up in the DOM tree, calling matchesSelector once per level.

matchesSelector is a bleeding edge feature (I don't think any browser supports it without prefix yet), but Sizzle (and thus, jQuery) has it.

I propose the use of the currently available matchesSelector functions, and the addition of a setMatchesSelectorFunc function, receiving a function(selector) -> boolean. Users can use that to pass in their shims.

This does not mean that querySelector should be dropped. Just that browsers with matchesSelector will have better delegation performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0