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

Predefined Globals Enhancement

Expand Messages
  • benxwhite
    It would be nice if the following predefined globals could be added to the browser array self top XDomainRequest and these to the standard array void
    Message 1 of 4 , Feb 23, 2012
      It would be nice if the following predefined globals could be added to the 'browser' array

      self
      top
      XDomainRequest

      and these to the 'standard' array

      void
      escape
      unescape
    • douglascrockford
      ... self is redundant. top is dangerous. I will not be exposing that by default. XDomainRequest is not standard. void is confusing. escape/unescape have been
      Message 2 of 4 , Feb 23, 2012
        --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@...> wrote:

        > It would be nice if the following predefined globals could be added to the 'browser' array
        >
        > self
        > top
        > XDomainRequest
        >
        > and these to the 'standard' array
        >
        > void
        > escape
        > unescape

        self is redundant.
        top is dangerous. I will not be exposing that by default.
        XDomainRequest is not standard.
        void is confusing.
        escape/unescape have been deprecated and should not be used.

        What would be nice about that?
      • benxwhite
        This is a pretty common bit of code that I would expect to pass validation. if (self !== top) { top.location = self.location; } Additionally, if you fee so
        Message 3 of 4 , Feb 23, 2012
          This is a pretty common bit of code that I would expect to pass validation.

          if (self !== top) {
          top.location = self.location;
          }

          Additionally, if you fee so strongly about some valid JavaScript methods (void, escape, unescape), shouldn't jslint warn us about them.
          e.g. escape has been deprecated use encodeURI or encodeURIComponent

          After all, isn't jslint intended to be our dutch uncle?

          I can see not including XDomainRequest, but it would be nice for framework developers to have some flag they could enable to support non-compliant browsers methods included in IE. (Similar to your 'windows' option)


          --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@> wrote:
          >
          > > It would be nice if the following predefined globals could be added to the 'browser' array
          > >
          > > self
          > > top
          > > XDomainRequest
          > >
          > > and these to the 'standard' array
          > >
          > > void
          > > escape
          > > unescape
          >
          > self is redundant.
          > top is dangerous. I will not be exposing that by default.
          > XDomainRequest is not standard.
          > void is confusing.
          > escape/unescape have been deprecated and should not be used.
          >
          > What would be nice about that?
          >
        • Joshua Bell
          ... in Workers. When writing code that may execute in either Window or Worker context, it s nice to use |self| consistently. Alternately, you can use this
          Message 4 of 4 , Feb 24, 2012
            On Thu, Feb 23, 2012 at 9:50 AM, douglascrockford <douglas@...>wrote:

            > **
            >
            >
            > --- In jslint_com@yahoogroups.com, "benxwhite" <ben.a.white@...> wrote:
            >
            > > It would be nice if the following predefined globals could be added to
            > the 'browser' array
            > >
            > > self
            >
            > self is redundant.
            >

            |self| is used to refer to the global scope when writing code that will run
            in Workers. When writing code that may execute in either Window or Worker
            context, it's nice to use |self| consistently.

            Alternately, you can use this pattern to wrap your script.

            (function (global) {
            // your code here...
            }(this));

            But the same argument applies to |window| in that case.


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.