From 03882dcccc585739074fcf53b10159f170ff2199 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 17 Nov 2014 16:32:33 -0800 Subject: [PATCH] refactor(ElementInjector): remove stale file and make StaticKeys private --- modules/core/src/compiler/element_injector.js | 23 +++++++++++++++---- modules/core/src/compiler/element_module.js | 1 - modules/core/src/compiler/static_keys.js | 19 --------------- 3 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 modules/core/src/compiler/element_module.js delete mode 100644 modules/core/src/compiler/static_keys.js diff --git a/modules/core/src/compiler/element_injector.js b/modules/core/src/compiler/element_injector.js index 7c5083230a..1de7cedc1f 100644 --- a/modules/core/src/compiler/element_injector.js +++ b/modules/core/src/compiler/element_injector.js @@ -3,9 +3,7 @@ import {Math} from 'facade/math'; import {List, ListWrapper} from 'facade/collection'; import {Injector, Key, Dependency, bind, Binding, NoProviderError, ProviderError, CyclicDependencyError} from 'di/di'; import {Parent, Ancestor} from 'core/annotations/visibility'; -import {StaticKeys} from './static_keys'; -// Comment out as dartanalyzer does not look into @FIELD -// import {View} from './view'; +import {View} from 'core/compiler/view'; import {NgElement} from 'core/dom/element'; var _MAX_DIRECTIVE_CONSTRUCTION_COUNTER = 10; @@ -14,6 +12,21 @@ var MAX_DEPTH = Math.pow(2, 30) - 1; var _undefined = new Object(); +var _staticKeys; + +class StaticKeys { + constructor() { + //TODO: vsavkin Key.annotate(Key.get(View), 'static') + this.viewId = Key.get(View).id; + this.ngElementId = Key.get(NgElement).id; + } + + static instance() { + if (isBlank(_staticKeys)) _staticKeys = new StaticKeys(); + return _staticKeys; + } +} + class TreeNode { @FIELD('_parent:TreeNode') @FIELD('_head:TreeNode') @@ -89,13 +102,13 @@ export class PreBuiltObjects { Difference between di.Injector and ElementInjector -di.Injector (di.Module): +di.Injector: - imperative based (can create child injectors imperativly) - Lazy loading of code - Component/App Level services which are usually not DOM Related. -ElementInjector (ElementModule): +ElementInjector: - ProtoBased (Injector structure fixed at compile time) - understands @Ancestor, @Parent, @Child, @Descendent - Fast diff --git a/modules/core/src/compiler/element_module.js b/modules/core/src/compiler/element_module.js deleted file mode 100644 index 2487f92f44..0000000000 --- a/modules/core/src/compiler/element_module.js +++ /dev/null @@ -1 +0,0 @@ -export class ElementModule {} \ No newline at end of file diff --git a/modules/core/src/compiler/static_keys.js b/modules/core/src/compiler/static_keys.js deleted file mode 100644 index 608a1fbd6f..0000000000 --- a/modules/core/src/compiler/static_keys.js +++ /dev/null @@ -1,19 +0,0 @@ -import {View} from 'core/compiler/view'; -import {NgElement} from 'core/dom/element'; -import {Key} from 'di/di'; -import {isBlank} from 'facade/lang'; - -var _staticKeys; - -export class StaticKeys { - constructor() { - //TODO: vsavkin Key.annotate(Key.get(View), 'static') - this.viewId = Key.get(View).id; - this.ngElementId = Key.get(NgElement).id; - } - - static instance() { - if (isBlank(_staticKeys)) _staticKeys = new StaticKeys(); - return _staticKeys; - } -} \ No newline at end of file