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

Re: [jslint] Re: window

Expand Messages
  • AJ ONeal
    That is a nightmare! I just noticed that a few days ago and it was really upsetting to see even MORE global leakage... YUCK. AJ ONeal ... [Non-text portions of
    Message 1 of 9 , Mar 31, 2011
    • 0 Attachment
      That is a nightmare!

      I just noticed that a few days ago and it was really upsetting to see even
      MORE global leakage... YUCK.

      AJ ONeal


      On Thu, Mar 31, 2011 at 6:08 AM, Alexandre Morgaut <morgaut@...>wrote:

      >
      >
      > My biggest nightmare today is that recent browsers like Chrome, IE9, FF4
      > generate a global variable from the id of each HTMLElement of the
      > document...
      >
      > It is know possible in these browser to write
      >
      > domNode = myPanel;
      >
      > or
      >
      > domNode = window.myPanel;
      >
      > instead of
      >
      > domNode = document.getElementById('myPanel');
      >
      > or with jQuery:
      >
      > domNode = $('#myPanel');
      >
      > Let's imagine the effects of existing HTMLElements with id like "location",
      > "document", "event", "toolbar", or even "window"...
      >
      > What should be the list of reserved keywords for valid id value ?
      > All the BOM API ?
      > + APIs like Web Storages, Web Sockets... ?
      > + Global namespaces of common Ajax frameworks ?
      >
      > And what about future HTML5/W3C APIs ?
      > And what about future or private frameworks ???
      >
      > So ... "window.myPanel"
      > -> Bad practice isn't it ?
      >
      >
      >


      [Non-text portions of this message have been removed]
    • AJ ONeal
      I use this pattern: https://github.com/coolaj86/require-kiss-js I m also going to look into RequireJS in the near future. AJ ONeal ... [Non-text portions of
      Message 2 of 9 , Mar 31, 2011
      • 0 Attachment
        I use this pattern:
        https://github.com/coolaj86/require-kiss-js

        I'm also going to look into RequireJS in the near future.

        AJ ONeal

        On Tue, Mar 29, 2011 at 5:17 PM, Erik Eckhardt <erik@...> wrote:

        > If you were creating a specialized code library, what method would you use
        > to "namespace" all the functions in use by that library? Since functions
        > are
        > themselves globals, would you just create a single "master" object, itself
        > global, with all other variables inside of it? Then, in commons use, either
        > use this.fn() or libraryname.fn() all over the place instead of just fn()
        > when you want to use a function? And something similar for any variables
        > that are needed to control the operation of the code library (say it's a
        > popup widget that needs to keep track of all the open popups and whether a
        > particular popup template has been loaded via ajax or not)?
        >
        > On Tue, Mar 29, 2011 at 8:57 AM, Douglas Crockford <douglas@...
        > >wrote:
        >
        > >
        > >
        > > --- In jslint_com@yahoogroups.com, Erik Eckhardt <erik@...> wrote:
        > >
        > > > Is there some place an interested person could read about the good vs.
        > > bad
        > > > uses of `window`?
        > >
        > > The principle misuse is to access global variables. Global variables
        > should
        > > be avoided.
        > >
        > >
        > >
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >


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