   currentData: (path, equalsFunc) ->
     @constructor.currentData path, equalsFunc
 
-  # Useful in templates to get a reference to the component.
+  # Useful in templates or mixins to get a reference to the component.
   component: ->
-    @
+    component = @
+
+    loop
+      # If we are on a mixin without mixinParent, we cannot really get to the component, return null.
+      return null unless component.mixinParent
+
+      # Return current component unless there is a mixin parent.
+      return component unless mixinParent = component.mixinParent()
+      component = mixinParent
 
   # Caller-level component. In most cases the same as @, but in event handlers
   # it returns the component at the place where event originated (target component).

    return

  events: ->
    @_componentInternals ?= {}

    # In mixins we do not have a template instance. There is also
    # no reason for a template instance to extend a Blaze template.
    return [] unless @_componentInternals.templateInstance

    view = Tracker.nonreactive =>
      @_componentInternals.templateInstance().view

    callTemplateBaseHooks @, 'destroyed'

  isCreated: ->
    component = @component()

    component._componentInternals ?= {}
    component._componentInternals.isCreated ?= new ReactiveField false

    component._componentInternals.isCreated()

  isRendered: ->
    component = @component()

    component._componentInternals ?= {}
    component._componentInternals.isRendered ?= new ReactiveField false

    component._componentInternals.isRendered()

  isDestroyed: ->
    component = @component()

    component._componentInternals ?= {}
    component._componentInternals.isDestroyed ?= new ReactiveField false

    component._componentInternals.isDestroyed()

  insertDOMElement: (parent, node, before) ->
    before ?= null
