tillurdizzy / x2js

Automatically exported from code.google.com/p/x2js
0 stars 0 forks source link

Javascript syntax error Firefox - demo.html #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I tracked down a javascript syntax error in my application to x2js.

FIrefox 34.0.5
https://x2js.googlecode.com/hg/demo.html

- syntax error ... demo.html:1 
- the highlighted line in code is line 1:demo.html - <!doctype html>

The error is unhelpful and seems to point generally to a broken <script> tag. 
This is not the case in my application nor apparently on the demo page.

The demo page still works as expected but I feel it is worth taking note of.

I've searched project issues (keywords: syntax error firefox/firebug) but I 
don't see that this error has been previously reported.

Thanks for the project, it has made life easier having such a good library for 
converting xml<->json.

Kind regards,
Darryl

Original issue reported on code.google.com by darryljcousins on 18 Dec 2014 at 2:06

GoogleCodeExporter commented 9 years ago
Hi, I have the same issue.
I was able to track it and found where it comes from. It seems that the firefox 
DOM parser does like this code:

try {
  parsererrorNS = parser.parseFromString("INVALID", "text/xml").childNodes[0].namespaceURI;
}
catch(err) {                    
  parsererrorNS = null;
}

When trying to parse the INVALID string, firefox DOM parser shows this "syntax 
error" on HTML line 1 in the console, event if the conversion error is 
surrounded by try-catch.

Original comment by geoffrey...@gmail.com on 20 Feb 2015 at 7:37