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

2118Re: [jslint] Re: Double Indentation (UNCLASSIFIED)

Expand Messages
  • Erik Eckhardt
    Apr 6 9:33 AM
    • 0 Attachment
      That works to satisfy jslint, but if I'm chaining methods together then it
      gets a little weird:

      var z,
      i = $('<div></div>').css({
      width: '100%',
      height: '200px'
      }).append($('<p></p>')).css({
      color: 'blue'
      }),
      x,
      y;

      var z,
      i2 = $('<div></div>')
      .css({
      width: '100%',
      height: '200px'
      })
      .append($('<p></p>'))
      .css({
      color: 'blue'
      }),
      x,
      y;

      I like the second one better, despite how deep it gets, because it puts one
      chained method per line, at the beginning of the line. In the upper example,
      it makes it look like color: 'blue' is part of append, when it's not. Moving
      the .css({ to the next line after append now has some method lines starting
      with }) and some with . in an inconsistent fashion. The extra level of
      indentation keeps variable names at one indent and the method chaining in
      one so there's no confusion about what variable started the chaining.

      In the second example }) always ends a line and doesn't have a method coming
      after it. Methods are always introduced at the beginning of a line. It makes
      more sense to me.

      Douglas, what are you thoughts?

      Erik

      P.S. If the spaces didn't come through please let me know and I'll redo.

      On Wed, Apr 6, 2011 at 7:31 AM, Cheney, Edward A SSG RES USAR USARC <
      austin.cheney@...> wrote:

      >
      >
      > Classification: UNCLASSIFIED
      > The whitespace algorithm is not wrong in its error. The cause of your
      > problem is the ".css".
      > This this instead:
      >
      > var i = $('<p></p>').css({
      > width: '100%',
      > height: '200px'
      > }),
      > o = $('<div></div>').css({
      > position: 'absolute',
      > top: '0',
      > left: '0',
      > visibility: 'hidden',
      > width: '200px',
      > height: '150px',
      > overflow: 'hidden'
      > }),
      > w1,
      > h1,
      > w2,
      > h2;
      >
      > Thanks,
      > Austin Cheney, CISSP
      > http://prettydiff.com/
      > Classification: UNCLASSIFIED
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 4 messages in this topic