From 02d4a4294f20bab3b87f7babb43be00a0ee75bbf Mon Sep 17 00:00:00 2001 From: Vincent Wochnik Date: Mon, 20 Feb 2017 10:25:05 +0100 Subject: [PATCH] fix: Add check to getID() to return null if element has no set id (#22) --- src/getID.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/getID.js b/src/getID.js index c4c6ab1..6849cff 100644 --- a/src/getID.js +++ b/src/getID.js @@ -5,5 +5,11 @@ */ export function getID( el ) { - return `#${el.getAttribute( 'id' )}`; + const id = el.getAttribute( 'id' ); + + if( id !== null ) + { + return `#${id}`; + } + return null; }