From 1bb0e726d188d138e06955315c06f16e616b7574 Mon Sep 17 00:00:00 2001 From: Vincent Wochnik Date: Thu, 16 Feb 2017 09:45:34 +0100 Subject: [PATCH] Add check to getID() to return null if element has no set id --- 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; }