From 66d0e7c7524200de78c4e7fa4a3ec4dd61bc8041 Mon Sep 17 00:00:00 2001 From: Thomas Johansen Date: Wed, 19 Aug 2015 15:44:16 +0200 Subject: [PATCH 1/3] :memo: Attempt to document view resolution algorithm --- src/view-registry.coffee | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/view-registry.coffee b/src/view-registry.coffee index 0c533e9a8..67170d3b8 100644 --- a/src/view-registry.coffee +++ b/src/view-registry.coffee @@ -124,6 +124,24 @@ 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 + # heuristic 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 SpacePen view, which means it has a `jquery` property? + # If true, return the root DOM node (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. + # 5. Does the object have a `getViewClass` method? If true, use the method + # 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? From 675e9be262645da5b99cc07666b9db717ae0e239 Mon Sep 17 00:00:00 2001 From: Thomas Johansen Date: Wed, 19 Aug 2015 20:46:24 +0200 Subject: [PATCH 2/3] :fire: Remove mention of semi-deprecated view resolution step --- src/view-registry.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/view-registry.coffee b/src/view-registry.coffee index 67170d3b8..b02f3b600 100644 --- a/src/view-registry.coffee +++ b/src/view-registry.coffee @@ -137,8 +137,6 @@ class ViewRegistry # 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. - # 5. Does the object have a `getViewClass` method? If true, use the method - # 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. # From c16f252ab7fd79e77c11433f87926717ef3ef29e Mon Sep 17 00:00:00 2001 From: Thomas Johansen Date: Wed, 19 Aug 2015 20:54:39 +0200 Subject: [PATCH 3/3] :memo: Rephrase view resolution docs --- src/view-registry.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/view-registry.coffee b/src/view-registry.coffee index b02f3b600..6af7bd024 100644 --- a/src/view-registry.coffee +++ b/src/view-registry.coffee @@ -127,13 +127,13 @@ class ViewRegistry # ## View Resolution Algorithm # # The view associated with the object is resolved using the following - # heuristic sequence + # 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 SpacePen view, which means it has a `jquery` property? - # If true, return the root DOM node (i.e. `object[0]`). + # 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.