Skip to content

Commit

Permalink
fix(utils): support window, array
Browse files Browse the repository at this point in the history
  • Loading branch information
sculove committed Jul 19, 2017
1 parent fdbc233 commit 663ffeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egjs/axes",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc",
"description": "A module used to change the information of user action entered by various input devices such as touch screen or mouse into logical coordinates within the virtual coordinate system. The coordinate information sorted by time events occurred is provided if animations are made by user actions.",
"main": "dist/axes.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ export function $(param, multi = false) {
if (!multi) {
el = el.length >= 1 ? el[0] : undefined;
}
} else if (param === window) { // window
el = param;
} else if (param.nodeName &&
(param.nodeType === 1 || param.nodeType === 9)) { // HTMLElement, Document
(param.nodeType === 1 || param.nodeType === 9)) { // HTMLElement, Document
el = param;
} else if (("jQuery" in window && param instanceof jQuery) ||
param.constructor.prototype.jquery) { // jQuery
el = multi ? param.toArray() : param.get(0);
} else if (Array.isArray(param)) {
el = param.map(v => $(v));
if (!multi) {
el = el.length >= 1 ? el[0] : undefined;
}
}
return el;
}

0 comments on commit 663ffeb

Please sign in to comment.