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

Does JSLint parse DOM functions?

Expand Messages
  • paulur10
    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.
    Message 1 of 5 , Jun 12 5:08 PM
    • 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));
      }
    • Cheney, Edward A SSG RES USAR USARC
      paulur10, 1) If you attempting to access a window object you are not using the DOM. The DOM is based upon the document object as the tree root. 2) There
      Message 2 of 5 , Jun 12 6:56 PM
      • 0 Attachment
        paulur10,

        1) If you attempting to access a window object you are not using the DOM. The DOM is based upon the document object as the tree root.

        2) There exists no such thing, at least in accordance with standards, as document.documentElement. Instead try
        document.getElementById("theIDvaluehere").innerHTML = "your string to output here";

        Austin
        http://prettydiff.com/
      • Aseem Kishore
        ... document.documentElement. Instead try document.getElementById( theIDvaluehere ).innerHTML = your string to output here ; ??? It s part of DOM Level 2.
        Message 3 of 5 , Jun 12 11:09 PM
        • 0 Attachment
          > 2) There exists no such thing, at least in accordance with standards, as
          document.documentElement. Instead try
          document.getElementById("theIDvaluehere").innerHTML = "your string to output
          here";

          ???

          It's part of DOM Level 2.

          https://developer.mozilla.org/en/DOM/document.documentElement

          <https://developer.mozilla.org/en/DOM/document.documentElement>Aseem

          On Sat, Jun 12, 2010 at 6:56 PM, Cheney, Edward A SSG RES USAR USARC <
          austin.cheney@...> wrote:

          >
          >
          > paulur10,
          >
          > 1) If you attempting to access a window object you are not using the DOM.
          > The DOM is based upon the document object as the tree root.
          >
          > 2) There exists no such thing, at least in accordance with standards, as
          > document.documentElement. Instead try
          > document.getElementById("theIDvaluehere").innerHTML = "your string to
          > output here";
          >
          > Austin
          > http://prettydiff.com/
          >
          >


          [Non-text portions of this message have been removed]
        • Douglas Crockford
          ... JSLint s parse function was not intended to be used out of context, and it does not produce complete parse trees. You would do better to start with
          Message 4 of 5 , Jun 13 5:15 PM
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "paulur10" <paulur@...> wrote:
            >
            > 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.

            JSLint's parse function was not intended to be used out of context, and it does not produce complete parse trees. You would do better to start with javascript.crockford.com/tdop/
          • pauanyu
            1) The window object is usually implemented as the DOM defaultView: https://developer.mozilla.org/en/DOM:document.defaultView In addition, although the
            Message 5 of 5 , Jun 13 7:43 PM
            • 0 Attachment
              1) The "window" object is usually implemented as the DOM defaultView:

              https://developer.mozilla.org/en/DOM:document.defaultView

              In addition, although the "window" object itself may not be codified in the spec, it implements the EventTarget interface, and the addEventListener method IS part of the DOM spec.

              2) document.documentElement is a part of the DOM Core Level 2, as Aseem Kishore pointed out.

              --- In jslint_com@yahoogroups.com, "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@...> wrote:
              >
              > paulur10,
              >
              > 1) If you attempting to access a window object you are not using the DOM. The DOM is based upon the document object as the tree root.
              >
              > 2) There exists no such thing, at least in accordance with standards, as document.documentElement. Instead try
              > document.getElementById("theIDvaluehere").innerHTML = "your string to output here";
              >
              > Austin
              > http://prettydiff.com/
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.