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

Re: JSLint and DOM constructor types.

Expand Messages
  • Douglas Crockford
    ... I will add them when IE adds them. Currently, I think it is more helpful for JSLint to report that NodeList is not available on 80% of browsers.
    Message 1 of 4 , Aug 3, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "pauanyu" <pcxunlimited@...> wrote:
      >
      > JSLint doesn't like DOM types:
      >
      > Element
      > NodeList
      > etc.
      >
      > So you can't do (foo instanceof Element) to see if it's a HTMLElement, or (foo instanceof NodeList) to see if it's a NodeList.
      >
      > Currently I make it work by putting a /*global */ statement at the top of my programs:
      >
      > /*global Element, NodeList */
      >
      > Using "var Element, NodeList;" causes errors, so I -must- use the /*global */ construct.
      >
      > Any chance of JSLint becoming aware of the DOM types?

      I will add them when IE adds them. Currently, I think it is more helpful for JSLint to report that NodeList is not available on 80% of browsers.
    • pauanyu
      ... Understandable. Er, IE still holds 80% of the market share? If I recall, basically every browser other than IE supports NodeList, and that IE has closer to
      Message 2 of 4 , Aug 3, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        >
        > I will add them when IE adds them. Currently, I think it is more helpful for JSLint to report that NodeList is not available on 80% of browsers.
        >
        Understandable. Er, IE still holds 80% of the market share? If I recall, basically every browser other than IE supports NodeList, and that IE has closer to 68% market share (along with all the disclaimers about how unreliable market share tests are).
      • pauanyu
        ... By the way, I ran some tests in IE8. Apparently IE8 *does* support Element, but not NodeList: var body = document.getElementsByTagName( body );
        Message 3 of 4 , Aug 5, 2009
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > I will add them when IE adds them. Currently, I think it is more helpful for JSLint to report that NodeList is not available on 80% of browsers.
          >

          By the way, I ran some tests in IE8. Apparently IE8 *does* support Element, but not NodeList:


          var body = document.getElementsByTagName("body");
          console.log("Element: " + (body[0] instanceof Element)); // true
          console.log("NodeList: " + (body instanceof NodeList)); // false


          I have no clue whether IE7 or IE6 support Element, however.
        Your message has been successfully submitted and would be delivered to recipients shortly.