             attributes[key] = _.clone(attributes[key])
             # console.log('overwriting', key, attributes[key], value)
             for propname, val of value
+              # TODO: deal with method overrides here?
               attributes[key][propname] = val
           else if key is '$handlers' and key of attributes
             # console.log 'concat', attributes[key], value


    attributes = flattenattributes(el.attributes)

    # swallow builtin attributes
    for event in mouseEvents
      el.removeAttribute('on' + event)


      # register constraints last
      for name, value of @constraints
        # console.log 'binding constraint', name, value, @
        constraint = @constraintCallback(name, value)
        for bindexpression, binding of @constraints[name].bindings
          property = binding.property
          boundref = binding.compiled()
          boundref ?= boundref.$view
          # console.log 'binding to', property, 'on', boundref
          boundref.bind(property, constraint)
          
        @setAttribute(name, value())

      return

    # generate a callback for a constraint expression, e.g. x="${this.parent.baz.x + 10}"
    constraintCallback: (name, fn) ->
      # console.log('binding to constraint fn', name, fn, @)
      () =>
        # console.log 'setting', name, fn(), @
        @setAttribute(name, fn())

    set_parent: (parent) ->
      # console.log 'set_parent', parent, @
