Loading ...
Sorry, an error occurred while loading the content.

1337Does JSLint parse DOM functions?

Expand Messages
  • paulur10
    Jun 12, 2010
    • 0 Attachment
      I tried to use the parse() function of JSLint to parse the following three pieces of JavaScript code:
      1. function(b, c){var a = b + c; return a; }
      2. window.addEventListener('click', click_hanlder, true);
      3. document.documentElement.innerHTML;

      The outputs are the following:
      1. returns a correct tree.
      2. returns a tree with only one node of "window".
      3. crashes the browser.

      I'm wondering whether JSLint doesn't support DOM function.

      Here's the the way I used the parse() function, which is copied and pasted from the JSLint self-parse example, with replacing the "source" variable :

      try {
      parse = make_parse();
      var source = "something to parse";//replaced by the three inputs above
      tree = parse(source);
      if (tree) {
      document.write(JSON.stringify(tree, ['key', 'name', 'message',
      'value', 'arity', 'first', 'second', 'third', 'fourth'], 4));
      } catch (e) {
      document.write(JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
      'value', 'arity', 'first', 'second', 'third', 'fourth'], 4));
    • Show all 5 messages in this topic