Skip to content

Commit

Permalink
fix(Selectors): Find now always return a value
Browse files Browse the repository at this point in the history
When no element is find with getElementById, return an empty array
  • Loading branch information
lucaperret committed Aug 11, 2017
1 parent b6cab99 commit 473dda3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function find (selector, context = document) {
}
let elements
if (/^#[\w-]*$/.test(selector)) {
elements = document.getElementById(selector.substr(1))
elements = document.getElementById(selector.substr(1)) || []
} else if (/^\.[\w-]*$/.test(selector)) {
elements = context.getElementsByClassName(selector.slice(1))
} else if (/^\w+$/.test(selector)) {
Expand Down

0 comments on commit 473dda3

Please sign in to comment.