Skip to content

_closest #4

Description

@PAEz

There's a small error in it that if ctx is undefined it does nothing.

if( el && ctx){

really should be...

if( el ){

...since your defining ctx on the next line anyway.

Also, if you care about speed how about using matches/matchSelector, its alot faster.....
http://jsperf.com/closestagain
...and according to caniuse available in all modern browser except Opera Mini.

Oh, and thanks for making this, Ive looked a few times for something like this that doesnt use JQuery and this is the first thing thats ever popped up....well done.

EDIT: Actually I take the speed thing back as I just tested it in FF and yours won. I have a bad habit of only testing in Chrome because its the only browser I code for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions