           @quill.prepareFormat(format, value)
         else
           @quill.formatText(range, format, value, 'user')
-      this.setActive(input, value)
+      this.setActive(format, value)
+      triggering = false
       return false
     )
 
-  setActive: (input, value) ->
+  setActive: (format, value) ->
+    if value
+      @activeFormats[format] = value
+    else
+      delete @activeFormats[format]
+    input = this._getInput(format)
+    return unless input?
     if input.tagName == 'SELECT'
-      value = '' if _.isArray(value)
-      input.value = value
+      if value
+        value = '' if _.isArray(value)
+        DOM.selectOption(input, value)
+      else
+        DOM.resetSelect(input, false)
     else
-      DOM.addClass(input, 'sc-active')
+      DOM.toggleClass(input, 'sc-active', value)
 
   updateActive: (range) ->
-    return
     activeFormats = this._getActive(range)
-    _.each(@container.querySelectorAll('select'), _.bind(DOM.resetSelect))
-    _.each(@container.querySelectorAll('.sc-active'), (button) =>
-      DOM.removeClass(button, 'sc-active')
+    _.each(_.keys(@activeFormats), (name) =>
+      if activeFormats[name]?
+        this.setActive(name, activeFormats[name]) if activeFormats[name] != @activeFormats[name]
+      else
+        this.setActive(name, false)
     )
-    _.each(activeFormats, (value, key) =>
-      return unless value
-      input = this._getInput(key)
-      return unless input?
-      this.setActive(input, value)
+    _.each(activeFormats, (value, name) =>
+      this.setActive(name, value) unless @activeFormats[name]?
     )
 
   _getInput: (format) ->

    container: null

  @formats:
    BUTTON: {'bold', 'italic', 'strike', 'underline'}
    SELECT: {'align', 'background', 'color', 'font', 'size'}

  constructor: (@quill, @editorContainer, @options) ->
    throw new Error('container required for toolbar', @options) unless @options.container?
    @container = if _.isString(@options.container) then document.querySelector(@options.container) else @options.container
    _.each(@quill.options.formats, (format) =>
      if Toolbar.formats.BUTTON[format]?
        this.initFormat(format, 'click')

  initFormat: (format, eventName) ->
    input = this._getInput(format)
    return unless input?
    triggering = false
    DOM.addEventListener(input, eventName, =>
      return if triggering
      triggering = true
      value = if eventName == 'change' then input.options[input.selectedIndex].value else !DOM.hasClass(input, 'sc-active')
      @quill.focus()
      range = @quill.getSelection()
