Skip to content

Commit

Permalink
feat(getTarget): throw when string not in DOM (#622)
Browse files Browse the repository at this point in the history
Previously it when a string target was not found in the DOM via querySelector, it would just return the `null` and bomb elswhere
Now an error is thrown to help the developer track down the issue.

Closes #620
  • Loading branch information
TheSharpieOne committed Oct 6, 2017
1 parent 3fbd34c commit e71c427
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export function getTarget(target) {
if (selection === null) {
return document.querySelector(`#${target}`);
}
if (selection === null) {
throw new Error(`The target '${target}' could not be identified in the dom, tip: check spelling`);
}
return selection;
}

Expand Down

0 comments on commit e71c427

Please sign in to comment.