xmldoc icon indicating copy to clipboard operation
xmldoc copied to clipboard

lib/xmldoc.js should start with a semicolon ";" to avoid conflicts with sax

Open Ar-Kareem opened this issue 4 months ago • 1 comments

Hi, I included this script in my non-node project (angular to be specific). Obviously, I get the error in line 17 of lib/xmldoc.js because I haven't included sax image

However, Once I include sax before this script, I get the following error image Note that sax loads correctly and the error occurs in this script.

I managed to fix the issue by adding a single semicolon as the first character in lib/xmldoc.js like so image

After doing that the script works perfectly in my angular project.

The root issue is due to how scripts are concatenated. Thus without the semicolon, your script will try to call the output of the sax script which is undefined.

Here are some popular resources about the same issue of not having a semicolon at the beginning: https://stackoverflow.com/questions/23056249/what-does-the-leading-semicolon-in-a-javascript-file-mean/23056698 https://stackoverflow.com/questions/1873983/what-does-the-leading-semicolon-in-javascript-libraries-do?noredirect=1&lq=1 https://stackoverflow.com/questions/7145514/whats-the-purpose-of-starting-semi-colon-at-beginning-of-javascript

Ar-Kareem avatar Oct 13 '24 08:10 Ar-Kareem