Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix x$(window) behaviour on Safari 5.1. #60

Closed
wants to merge 1 commit into from

2 participants

Eduardo Felipe Fil Maj
Eduardo Felipe

On release 2.3.0 there is a bug caused by the fact that window objects in Safari define a numeric length of 0.

Because of the testing order xui calls slice(window), which in turn returned an empty array and breaks the code.

This patch just inverts the testing order and everything works.

Eduardo Felipe edufelipe Fix `x$(window)` behaviour on Safari 5.1.
`window` objects in Safari define a numeric length of 0, causing `slice(window)` to
be called, which in turn returned an empty array.

This little issue caused `x$(window)` to be the same as `x$()`.
49431c4
Fil Maj
Owner

Looks like this is also happening in Chrome 15. I'm going to merge your fix in but also try to add a test for this as well.

Fil Maj filmaj referenced this pull request from a commit
Fil Maj filmaj Adding a test for issue #60 41e4dd0
Fil Maj
Owner

I've merged this in @ 3c9fcad. Also added a test for this @ 41e4dd0.

Thank you for your contribution!

P.S. added you to the contributor list @edufelipe :)

Fil Maj filmaj closed this
Eduardo Felipe

Thanks a lot @filmaj!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2011
  1. Eduardo Felipe

    Fix `x$(window)` behaviour on Safari 5.1.

    edufelipe authored
    `window` objects in Safari define a numeric length of 0, causing `slice(window)` to
    be called, which in turn returned an empty array.
    
    This little issue caused `x$(window)` to be the same as `x$()`.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/base.js
6 src/base.js
View
@@ -175,12 +175,12 @@ xui.fn = xui.prototype = {
ele = slice(ele);
} else if (q instanceof Array) {
ele = q;
- } else if (q.toString() == '[object NodeList]' ||
-q.toString() == '[object HTMLCollection]' || typeof q.length == 'number') {
- ele = slice(q);
} else if (q.nodeName || q === window) { // only allows nodes in
// an element was passed in
ele = [q];
+ } else if (q.toString() == '[object NodeList]' ||
+q.toString() == '[object HTMLCollection]' || typeof q.length == 'number') {
+ ele = slice(q);
}
}
// disabling the append style, could be a plugin (found in more/base):
Something went wrong with that request. Please try again.