Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use a "called" flag instead of attribs.length, so that we can safely …

…remove attribs and add other args
  • Loading branch information...
commit 74e17143a405c04eb3c402bf64ec892b24eb923b 1 parent 2c42545
Brandon Bloom authored

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. +6 4 lib/convert.coffee
10 lib/convert.coffee
@@ -36,6 +36,7 @@ exports.convert = (html, stream, options, callback) ->
36 36
37 37 tag: (tag) ->
38 38 code = prefix + tag.name
  39 + called = false
39 40
40 41 # Force attribute ordering of `id`, `class`, then others.
41 42 attribs = []
@@ -54,11 +55,12 @@ exports.convert = (html, stream, options, callback) ->
54 55 attribs = for [key, value] in attribs
55 56 " #{key}: #{stringLiteral value}"
56 57 code += attribs.join(',')
  58 + called ||= attribs.length > 0
57 59
58 60 # Render content
59 61 endTag = (suffix) =>
60 62 if suffix
61   - code += ',' if attribs.length > 0
  63 + code += ',' if called
62 64 code += suffix
63 65 emit code
64 66 if (children = tag.children)?
@@ -67,10 +69,10 @@ exports.convert = (html, stream, options, callback) ->
67 69 else
68 70 endTag ' ->'
69 71 nest -> visit.array children
70   - else if attribs.length == 0
71   - endTag('()')
72   - else
  72 + else if called
73 73 endTag()
  74 + else
  75 + endTag('()')
74 76
75 77 text: (text) ->
76 78 return if text.data.match /^\s*$/

0 comments on commit 74e1714

Please sign in to comment.
Something went wrong with that request. Please try again.