<NME> UIKitRenderer.swift
<BEF> //
//  UIKitRenderer.swift
//  TemplateKit
//
//  Created by Matias Cudich on 9/3/16.
//  Copyright © 2016 Matias Cudich. All rights reserved.
//

import Foundation

public enum ElementType: ElementRepresentable {
  case box
  case button
  case text
  case textField
  case image
  case table
  case collection
  case activityIndicator
  case view(UIView)
  case component(ComponentCreation.Type)

  public var tagName: String {
    switch self {
    case .box:
      return "box"
    case .text:
      return "text"
    case .textField:
      return "textfield"
    case .image:
      return "image"
    case .button:
      return "button"
    case .table:
      return "table"
    }
  }

  public func make(_ element: Element, _ owner: Node?) -> Node {
    switch self {
    case .box:
      return NativeNode<Box>(element: element as! ElementData<Box.PropertiesType>, children: element.children?.map { $0.build(with: owner, context: nil) }, owner: owner)
    case .text:
      return NativeNode<Text>(element: element as! ElementData<Text.PropertiesType>, owner: owner)
    case .textField:
      return NativeNode<TextField>(element: element as! ElementData<TextField.PropertiesType>, owner: owner)
    case .image:
      return NativeNode<Image>(element: element as! ElementData<Image.PropertiesType>, owner: owner)
    case .button:
      return Button(element: element, children: nil, owner: owner)
    case .view(let view):
      return ViewNode(view: view, element: element as! ElementData<DefaultProperties>, owner: owner)
    case .component(let ComponentType as ComponentCreation.Type):
      return ComponentType.init(element: element, children: nil, owner: owner)
    default:
      fatalError("Unknown element type")
    }
      return Button(element: element, children: nil, owner: owner, context: context)
    case (.table, let element as ElementData<TableProperties>):
      return Table(element: element, children: nil, owner: owner, context: context)
    case (.collection, let element as ElementData<CollectionProperties>):
      return Collection(element: element, children: nil, owner: owner, context: context)
    case (.activityIndicator, let element as ElementData<ActivityIndicator.PropertiesType>):
      return NativeNode<ActivityIndicator>(element: element, owner: owner, context: context)
    case (.view(let view), let element as ElementData<DefaultProperties>):
      return ViewNode(view: view, element: element, owner: owner, context: context)
    case (.component(let ComponentType), _):
      return ComponentType.init(element: element, children: nil, owner: owner, context: context)
    default:
      fatalError("Supplied element \(element) does not match type \(self)")
    }
  }

  public func equals(_ other: ElementRepresentable) -> Bool {
    guard let otherType = other as? ElementType else {
      return false
    }
    return self == otherType
  }
}

public func ==(lhs: ElementType, rhs: ElementType) -> Bool {
  switch (lhs, rhs) {
  case (.box, .box), (.button, .button), (.text, .text), (.image, .image), (.textField, .textField), (.table, .table), (.activityIndicator, .activityIndicator), (.collection, .collection):
    return true
  case (.view(let lhsView), .view(let rhsView)):
    return lhsView === rhsView
  case (.component(let lhsClass), .component(let rhsClass)):
    return lhsClass == rhsClass
  default:
    return false
  }
}

class DefaultContext: Context {
  let templateService: TemplateService = XMLTemplateService()
  let updateQueue: DispatchQueue = DispatchQueue(label: "UIKitRenderer")
}

public class UIKitRenderer: Renderer {
  public typealias ViewType = UIView

  public static let defaultContext: Context = DefaultContext()
}

<MSG> Always pass through context and fix loading bug

<DFF> @@ -37,22 +37,22 @@ public enum ElementType: ElementRepresentable {
     }
   }
 
-  public func make(_ element: Element, _ owner: Node?) -> Node {
+  public func make(_ element: Element, _ owner: Node?, _ context: Context?) -> Node {
     switch self {
     case .box:
-      return NativeNode<Box>(element: element as! ElementData<Box.PropertiesType>, children: element.children?.map { $0.build(with: owner, context: nil) }, owner: owner)
+      return NativeNode<Box>(element: element as! ElementData<Box.PropertiesType>, children: element.children?.map { $0.build(with: owner, context: nil) }, owner: owner, context: context)
     case .text:
-      return NativeNode<Text>(element: element as! ElementData<Text.PropertiesType>, owner: owner)
+      return NativeNode<Text>(element: element as! ElementData<Text.PropertiesType>, owner: owner, context: context)
     case .textField:
-      return NativeNode<TextField>(element: element as! ElementData<TextField.PropertiesType>, owner: owner)
+      return NativeNode<TextField>(element: element as! ElementData<TextField.PropertiesType>, owner: owner, context: context)
     case .image:
-      return NativeNode<Image>(element: element as! ElementData<Image.PropertiesType>, owner: owner)
+      return NativeNode<Image>(element: element as! ElementData<Image.PropertiesType>, owner: owner, context: context)
     case .button:
-      return Button(element: element, children: nil, owner: owner)
+      return Button(element: element, children: nil, owner: owner, context: context)
     case .view(let view):
-      return ViewNode(view: view, element: element as! ElementData<DefaultProperties>, owner: owner)
+      return ViewNode(view: view, element: element as! ElementData<DefaultProperties>, owner: owner, context: context)
     case .component(let ComponentType as ComponentCreation.Type):
-      return ComponentType.init(element: element, children: nil, owner: owner)
+      return ComponentType.init(element: element, children: nil, owner: owner, context: context)
     default:
       fatalError("Unknown element type")
     }

Always pass through context and fix loading bug