From d59d5a92923a9a3cc6bd3778e11dee12ae5b4a88 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 28 May 2014 13:36:16 +0000 Subject: [PATCH] Twenty Fourteen: Avoid passing an empty string to document.getElementById(). props nabil_kadimi. fixes #28340. Built from https://develop.svn.wordpress.org/trunk@28598 git-svn-id: http://core.svn.wordpress.org/trunk@28423 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyfourteen/js/functions.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentyfourteen/js/functions.js b/wp-content/themes/twentyfourteen/js/functions.js index ea656d8077..3ec30fef0b 100644 --- a/wp-content/themes/twentyfourteen/js/functions.js +++ b/wp-content/themes/twentyfourteen/js/functions.js @@ -40,7 +40,13 @@ * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ */ _window.on( 'hashchange.twentyfourteen', function() { - var element = document.getElementById( location.hash.substring( 1 ) ); + var hash = location.hash.substring( 1 ), element; + + if ( ! hash ) { + return; + } + + element = document.getElementById( hash ); if ( element ) { if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {