diff --git a/docs/build-instructions/linux.md b/docs/build-instructions/linux.md index 13b03a9bf..fd53b9612 100644 --- a/docs/build-instructions/linux.md +++ b/docs/build-instructions/linux.md @@ -24,7 +24,7 @@ Ubuntu LTS 12.04 64-bit is the recommended platform. ### Fedora / CentOS / RHEL -* `sudo yum --assumeyes install make gcc gcc-c++ glibc-devel git-core libgnome-keyring-devel rpmdevtools` +* `sudo dnf --assumeyes install make gcc gcc-c++ glibc-devel git-core libgnome-keyring-devel rpmdevtools` * Instructions for [Node.js](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#fedora). ### Arch diff --git a/spec/view-registry-spec.coffee b/spec/view-registry-spec.coffee index a12d46dde..fa3e5ba1f 100644 --- a/spec/view-registry-spec.coffee +++ b/spec/view-registry-spec.coffee @@ -26,6 +26,14 @@ describe "ViewRegistry", -> expect(node.textContent).toBe "Hello" expect(node.spacePenView).toBe view + describe "when passed an object with an element property", -> + it "returns the element property if it's an instance of HTMLElement", -> + class TestComponent + constructor: -> @element = document.createElement('div') + + component = new TestComponent + expect(registry.getView(component)).toBe component.element + describe "when passed a model object", -> describe "when a view provider is registered matching the object's constructor", -> it "constructs a view element and assigns the model on it", -> diff --git a/src/view-registry.coffee b/src/view-registry.coffee index ca9b7cdb7..6af7bd024 100644 --- a/src/view-registry.coffee +++ b/src/view-registry.coffee @@ -124,6 +124,22 @@ class ViewRegistry # * `object` The object for which you want to retrieve a view. This can be a # pane item, a pane, or the workspace itself. # + # ## View Resolution Algorithm + # + # The view associated with the object is resolved using the following + # sequence + # + # 1. Is the object an instance of `HTMLElement`? If true, return the object. + # 2. Does the object have a property named `element` with a value which is + # an instance of `HTMLElement`? If true, return the property value. + # 3. Is the object a jQuery object, indicated by the presence of a `jquery` + # property? If true, return the root DOM element (i.e. `object[0]`). + # 4. Has a view provider been registered for the object? If true, use the + # provider to create a view associated with the object, and return the + # view. + # + # If no associated view is returned by the sequence an error is thrown. + # # Returns a DOM element. getView: (object) -> return unless object? @@ -138,6 +154,8 @@ class ViewRegistry createView: (object) -> if object instanceof HTMLElement object + else if object?.element instanceof HTMLElement + object.element else if object?.jquery object[0] else if provider = @findProvider(object)