 
   @DEFAULT_STYLE = new Style
 
+  updateNode: ->
 
+    for own attr, value of @style.getAttributes()
+      @node.setAttribute attr, value

$ = require 'jquery'
module.exports = class StyledText
  COLOR_NAMES = ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White", "BrightBlack", "BrightRed", "BrightGreen", "BrightYellow", "BrightBlue", "BrightMagenta", "BrightCyan", "BrightWhite"]

  constructor: (text, style) ->
    @text = text
    @style = style
    @spanForced = false
    @node = null

  getNode: ->
    if not @node?
      if not @style.isDefault() or @spanForced
        @node = $(global.document.createElement("span"))
        @node.text @text
        @updateNode()
      else
        @node = global.document.createTextNode @text
    @node

  updateNode: ->
    @node.attr @style.getAttributes()

  class Style
    constructor: ->


    equals: (other) ->
      @bold is other.bold and @underlined is other.underlined and @inverse is other.inverse and @textColor is other.textColor and @backgroundColor is other.backgroundColor
    return @node

    getAttributes: ->
      classes = []
