I've implemented an instant search function using javascript on my jekyll site: https://cecilialee.github.io (Repository: https://github.com/cecilialee/cecilialee.github.io)
It works perfectly on Chrome and Firefox. However, when I test it on Safari, no matter on Mac or iPhone, the script doesn't seem working..
What can I do?
Ok I found the answer.
When I inspect on Safari, I found SyntaxError: Can't create duplicate variable that shadows a global property: 'results'
.
This is apparently a problem Safari has with declaring a let/const variable that shares the same name as a selected id attribute. I had some variables declared with const as you did and got the same error. Changed to let and still got it. Changed to var and it worked.
Reference: "can't create duplicate variable that shadows a global property"
Hence, I changed some of my JavaScript const to avoid duplication with id. And the script works like a charm again!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With