Skip to content

Commit

Permalink
docs(changelog): bumping version to 2.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenie committed Jun 14, 2018
1 parent 08b77b3 commit 1d79e92
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## <small>2.0.8 (2018-06-14)</small>

* fix(gulp): don't verify commit for release ([08b77b3](https://github.com/lbenie/qselector/commit/08b77b3))
* chore(fix gulp): fix gulp ([dd0f5cf](https://github.com/lbenie/qselector/commit/dd0f5cf))
* docs(changelog): bumping version to 2.0.7 ([c2c325a](https://github.com/lbenie/qselector/commit/c2c325a))



## <small>2.0.7 (2018-06-13)</small>

* fix(husky): fixes deploy command ([e8a2889](https://github.com/lbenie/qselector/commit/e8a2889))
Expand Down
62 changes: 31 additions & 31 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import isDom from 'is-dom';

const errorSelector = 'Selector does not exists in the DOM';
const queryType = {
single: true,
multiple: false,
single: true,
multiple: false,
};
const isNanOrInfinite = (el, selector) => {
const result = [
Number.isNaN(el),
Number.isNaN(selector),
Number.isFinite(el),
Number.isFinite(selector),
];
return result.some(x => x);
const result = [
Number.isNaN(el),
Number.isNaN(selector),
Number.isFinite(el),
Number.isFinite(selector),
];
return result.some(x => x);
};
const errorHanler = (isSingle, { el, selector }) => {
const root = document.querySelector(el);
const isNan = isNanOrInfinite(el, selector);
if (isNan && isNan.toString().length !== 0) {
throw new Error(errorSelector);
} else if (isSingle) {
const root = document.querySelector(el);
const isNan = isNanOrInfinite(el, selector);
if (isNan && isNan.toString().length !== 0) {
throw new Error(errorSelector);
}
else if (isSingle) {
return selector ?
isDom(root.querySelector(selector)) :
isDom(root);
}
return selector ?
isDom(root.querySelector(selector)) :
isDom(root);
}
return selector ?
isDom(...root.querySelectorAll(selector)) :
isDom(...Array.from(document.querySelectorAll(el)));
isDom(...root.querySelectorAll(selector)) :
isDom(...Array.from(document.querySelectorAll(el)));
};
const core = (type, ...args) => {
const isSingle = type === queryType.single;
const [el, selector] = args;
const root = document.querySelector(el);
if (errorHanler(isSingle, { el, selector })) {
if (selector) {
return isSingle ? root.querySelector(selector) : [...root.querySelectorAll(selector)];
const isSingle = type === queryType.single;
const [el, selector] = args;
const root = document.querySelector(el);
if (errorHanler(isSingle, { el, selector })) {
if (selector) {
return isSingle ? root.querySelector(selector) : [...root.querySelectorAll(selector)];
}
return isSingle ? root : Array.from(document.querySelectorAll(el));
}
return isSingle ? root : Array.from(document.querySelectorAll(el));
}
throw new Error(errorSelector);
throw new Error(errorSelector);
};
const $ = (el, selector) => core(queryType.single, el, selector);
const $$ = (el, selector) => core(queryType.multiple, el, selector);
export { $, $$ };
export { $, $$, };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qselector",
"version": "2.0.7",
"version": "2.0.8",
"description": "Aliases for querySelector & querySelectorAll",
"keywords": [
"query",
Expand Down

0 comments on commit 1d79e92

Please sign in to comment.