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

Re: /*properties*/ and /*global*/ now respect function scope

Expand Messages
  • jeddahbill
    ... Thank you!
    Message 1 of 4 , Mar 7, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "jeddahbill" <jeddahbill@...> wrote:
      >
      >
      >
      > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
      > >
      > > The /*properties*/ (formerly known as /*members*/) and the /*global*/ directives, when placed in a function, do not influence the environment outside of the function.
      > >
      > > So in this example, function a gets no warnings, but function b does.
      > >
      > >
      > > ````function a(x) {
      > > ````````/*global window*/
      > > ````````/*properties location, href*/
      > > ````````window.location.href = x;
      > > ````}
      > > ````
      > > ````function b(x) {
      > > ````````window.location.href = x;
      > > ````}
      > >
      >
      > The new implementation of /*properties*/ is causing problems.
      > Consider the following code:
      >
      > (function () {
      > ````var x;
      > ````x = {
      > ````````fa: function (arg) {
      > ````````````return arg * arg;
      > ````````}
      > ````};
      > }());
      >
      > ...for which jslint produces this error:
      >
      > Problem at line 6 character 9: Unexpected property 'fa'.
      >
      > I did not define /*properties*/ - at any scope - and, therefore, did not expect to be presented with a 'properties' error;
      >

      Thank you!
    Your message has been successfully submitted and would be delivered to recipients shortly.