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

snack.wrap on non-existent element returns length of 1 #28

Open
jenshedqvist opened this issue Feb 27, 2012 · 2 comments
Open

snack.wrap on non-existent element returns length of 1 #28

jenshedqvist opened this issue Feb 27, 2012 · 2 comments

Comments

@jenshedqvist
Copy link

When I run snack.wrap on an element that doesn't exist in the DOM I expect it to return an object with length of zero (0). Alternatively "undefined". This is needed to test if an element exists.

This is what I get when I run snack.wrap on an non-existent element today:

0 []

id 16

length 1

addClass function()

attach function()

data function()

delegate function()

detach function()

each function()

fire function()

removeClass function()

@mariussmit
Copy link

I've changed line 154 (in my version of snack.js) from

wrapper.length = l 

to

wrapper.length = (l == 1 && nodes[0].nodeName === undefined) ? 0 : l

Haven't tested rigorously but it works for me so far.

@artvolk
Copy link

artvolk commented Nov 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants