Skip to content

Commit

Permalink
fix: Add check to getID() to return null if element has no set id (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
vwochnik authored and AvraamMavridis committed Feb 20, 2017
1 parent 9a6d651 commit 02d4a42
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/getID.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
*/
export function getID( el )
{
return `#${el.getAttribute( 'id' )}`;
const id = el.getAttribute( 'id' );

if( id !== null )
{
return `#${id}`;
}
return null;
}

0 comments on commit 02d4a42

Please sign in to comment.