Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

catching the jQuery parseXML exception #11208

Open
repinel opened this Issue · 4 comments

3 participants

@repinel

I'm not sure if it's an issue, but shouldn't the following code throw an exception and reach the catch block?

try {
jQuery.parseXML('foo');
} catch(e) {
console.log(e.message);
}

@JamesMGreene
Collaborator
  • What OS? What version?
  • What version of PhantomJS?
  • What version of jQuery?
  • What is the context of this script?
    • An existing script on an existing page?
    • A PhantomJS-injected script onto an existing page?
    • A page.evaluate call to an existing page?
    • Run in the PhantomJS outer context?
    • REPL mode?
@JamesMGreene
Collaborator

(But the expectation would be: "yes, it should".)

@repinel

Actually, my example with just 'foo' is working properly. I am having problems with something like '<foo></foogoo>'.

  • What OS? What version? Ubuntu 12.10 AMD64 and Windows 7 64-bit
  • What version of PhantomJS? PhantomJS 1.9.0
  • What version of jQuery? Happened with 1.6.1 and 1.8.2
  • What is the context of this script?
    • An existing script on an existing page?
    • A PhantomJS-injected script onto an existing page?
    • A page.evaluate call to an existing page?
    • Run in the PhantomJS outer context?
    • REPL mode?
console.log('Started');

var page = require('webpage').create();

page.onConsoleMessage = function(msg) {
  console.log(msg);
};

page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", function() {
    console.log('Loaded jQuery');
    page.evaluate(function() {
        try {
          console.log('Parsing XML');
          var doc = jQuery.parseXML('<foo></foogoo>');
          console.log('XML is valid? ' + (doc.length == 1));
        } catch(e) {
          console.log(e.message);
        }
    });
    phantom.exit();
});

The same JavaScript code is working as expected on jsFiddle http://jsfiddle.net/u4Amm/

@mars

Currently experiencing this issue too.

  • What OS? What version? Mac OS X 10.9.1
  • What version of PhantomJS? PhantomJS 1.9.2
  • What version of jQuery? jQuery 1.10.1
  • What is the context of this script? An existing script on an existing page: running a Jasmine spec suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.