This repository was archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
refactor(Compiler): Try removing all computeNode() calls. #1469
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:angular/angular.dart' as angular; | ||
|
||
// This is silly, but just for simplified testing. | ||
import 'import_prefixes.dart' as prefixed; | ||
|
||
@angular.Component( | ||
selector: 'parent-comp', | ||
directives: [ | ||
prefixed.ChildComponent, | ||
], | ||
template: '<child-comp [myType]="input"></child-comp>', | ||
) | ||
class ParentComponent { | ||
final input = new prefixed.MyType(); | ||
} | ||
|
||
@angular.Component( | ||
selector: 'child-cmp', | ||
template: r''' | ||
{{myType}} | ||
''', | ||
) | ||
class ChildComponent { | ||
@angular.Input() | ||
prefixed.MyType myType; | ||
} | ||
|
||
class MyType {} |
31 changes: 31 additions & 0 deletions
31
_goldens/test/_files/directives/import_prefixes.outline.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// ignore_for_file: library_prefixes,unused_import,no_default_super_constructor_explicit,duplicate_import,unused_shown_name | ||
// The .template.dart files also export the user code. | ||
export 'import_prefixes.dart'; | ||
|
||
// Required for referencing runtime code. | ||
import 'dart:html'; | ||
import 'package:angular/angular.dart'; | ||
import 'package:angular/src/core/change_detection/directive_change_detector.dart'; | ||
import 'package:angular/src/core/linker/app_view.dart'; | ||
|
||
// Required for specifically referencing user code. | ||
import 'import_prefixes.dart' as _user; | ||
|
||
// Required for "type inference" (scoping). | ||
|
||
// For @Component class ParentComponent. | ||
external List<dynamic> get styles$ParentComponent; | ||
external ComponentFactory<_user.ParentComponent> get ParentComponentNgFactory; | ||
external AppView<_user.ParentComponent> viewFactory_ParentComponent0(AppView<dynamic> parentView, int parentIndex); | ||
class ViewParentComponent0 extends AppView<_user.ParentComponent> { | ||
external ViewParentComponent0(AppView<dynamic> parentView, int parentIndex); | ||
} | ||
// For @Component class ChildComponent. | ||
external List<dynamic> get styles$ChildComponent; | ||
external ComponentFactory<_user.ChildComponent> get ChildComponentNgFactory; | ||
external AppView<_user.ChildComponent> viewFactory_ChildComponent0(AppView<dynamic> parentView, int parentIndex); | ||
class ViewChildComponent0 extends AppView<_user.ChildComponent> { | ||
external ViewChildComponent0(AppView<dynamic> parentView, int parentIndex); | ||
} | ||
|
||
external void initReflector(); |
178 changes: 178 additions & 0 deletions
178
_goldens/test/_files/directives/import_prefixes.template.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
// ************************************************************************** | ||
// Generator: Instance of 'Compiler' | ||
// ************************************************************************** | ||
|
||
// ignore_for_file: cancel_subscriptions,constant_identifier_names,duplicate_import,non_constant_identifier_names,library_prefixes,UNUSED_IMPORT,UNUSED_SHOWN_NAME | ||
import 'import_prefixes.dart'; | ||
export 'import_prefixes.dart'; | ||
import 'package:angular/angular.dart' as angular; | ||
import 'import_prefixes.dart' as prefixed; | ||
import 'package:angular/src/di/reflector.dart' as _ngRef; | ||
import 'package:angular/angular.template.dart' as _ref0; | ||
import 'package:angular/src/core/linker/app_view.dart'; | ||
import 'import_prefixes.dart' as import1; | ||
import 'dart:html' as import2; | ||
import 'package:angular/src/core/render/api.dart'; | ||
import 'package:angular/src/core/linker/view_type.dart' as import4; | ||
import 'package:angular/src/core/change_detection/change_detection.dart'; | ||
import 'package:angular/src/core/linker/app_view_utils.dart' as import6; | ||
import 'package:angular/src/runtime.dart' as import7; | ||
import 'package:angular/angular.dart'; | ||
|
||
final List<dynamic> styles$ParentComponent = const []; | ||
|
||
class ViewParentComponent0 extends AppView<import1.ParentComponent> { | ||
import2.Element _el_0; | ||
static RenderComponentType _renderType; | ||
ViewParentComponent0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) { | ||
rootEl = import2.document.createElement('parent-comp'); | ||
_renderType ??= import6.appViewUtils.createRenderType((import7.isDevMode ? 'asset:_goldens/test/_files/directives/import_prefixes.dart' : null), ViewEncapsulation.None, styles$ParentComponent); | ||
setupComponentType(_renderType); | ||
} | ||
@override | ||
ComponentRef<import1.ParentComponent> build() { | ||
final _rootEl = rootEl; | ||
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl); | ||
var doc = import2.document; | ||
_el_0 = createAndAppend(doc, 'child-comp', parentRenderNode); | ||
init(const [], null); | ||
return null; | ||
} | ||
|
||
@override | ||
void detectChangesInternal() { | ||
final import1.ParentComponent _ctx = ctx; | ||
bool firstCheck = (this.cdState == 0); | ||
if (firstCheck) { | ||
if (!identical(_ctx.input, null)) { | ||
setProp(_el_0, 'myType', _ctx.input); | ||
} | ||
} | ||
} | ||
} | ||
|
||
AppView<import1.ParentComponent> viewFactory_ParentComponent0(AppView<dynamic> parentView, int parentIndex) { | ||
return new ViewParentComponent0(parentView, parentIndex); | ||
} | ||
|
||
final List<dynamic> styles$ParentComponentHost = const []; | ||
|
||
class _ViewParentComponentHost0 extends AppView<import1.ParentComponent> { | ||
ViewParentComponent0 _compView_0; | ||
import1.ParentComponent _ParentComponent_0_5; | ||
_ViewParentComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways); | ||
@override | ||
ComponentRef<import1.ParentComponent> build() { | ||
_compView_0 = new ViewParentComponent0(this, 0); | ||
rootEl = _compView_0.rootEl; | ||
_ParentComponent_0_5 = new import1.ParentComponent(); | ||
_compView_0.create(_ParentComponent_0_5, projectableNodes); | ||
init0(rootEl); | ||
return new ComponentRef(0, this, rootEl, _ParentComponent_0_5); | ||
} | ||
|
||
@override | ||
void detectChangesInternal() { | ||
_compView_0.detectChanges(); | ||
} | ||
|
||
@override | ||
void destroyInternal() { | ||
_compView_0?.destroy(); | ||
} | ||
} | ||
|
||
AppView<import1.ParentComponent> viewFactory_ParentComponentHost0(AppView<dynamic> parentView, int parentIndex) { | ||
return new _ViewParentComponentHost0(parentView, parentIndex); | ||
} | ||
|
||
const ComponentFactory<import1.ParentComponent> _ParentComponentNgFactory = const ComponentFactory('parent-comp', viewFactory_ParentComponentHost0, _ParentComponentMetadata); | ||
ComponentFactory<import1.ParentComponent> get ParentComponentNgFactory { | ||
return _ParentComponentNgFactory; | ||
} | ||
|
||
final List<dynamic> styles$ChildComponent = const []; | ||
|
||
class ViewChildComponent0 extends AppView<import1.ChildComponent> { | ||
import2.Text _text_0; | ||
var _expr_0; | ||
static RenderComponentType _renderType; | ||
ViewChildComponent0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.component, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways) { | ||
rootEl = import2.document.createElement('child-cmp'); | ||
_renderType ??= import6.appViewUtils.createRenderType((import7.isDevMode ? 'asset:_goldens/test/_files/directives/import_prefixes.dart' : null), ViewEncapsulation.None, styles$ChildComponent); | ||
setupComponentType(_renderType); | ||
} | ||
@override | ||
ComponentRef<import1.ChildComponent> build() { | ||
final _rootEl = rootEl; | ||
final import2.HtmlElement parentRenderNode = initViewRoot(_rootEl); | ||
_text_0 = new import2.Text(''); | ||
parentRenderNode.append(_text_0); | ||
init(const [], null); | ||
return null; | ||
} | ||
|
||
@override | ||
void detectChangesInternal() { | ||
final import1.ChildComponent _ctx = ctx; | ||
final currVal_0 = import6.interpolate0(_ctx.myType); | ||
if (import6.checkBinding(_expr_0, currVal_0)) { | ||
_text_0.text = currVal_0; | ||
_expr_0 = currVal_0; | ||
} | ||
} | ||
} | ||
|
||
AppView<import1.ChildComponent> viewFactory_ChildComponent0(AppView<dynamic> parentView, int parentIndex) { | ||
return new ViewChildComponent0(parentView, parentIndex); | ||
} | ||
|
||
final List<dynamic> styles$ChildComponentHost = const []; | ||
|
||
class _ViewChildComponentHost0 extends AppView<import1.ChildComponent> { | ||
ViewChildComponent0 _compView_0; | ||
import1.ChildComponent _ChildComponent_0_5; | ||
_ViewChildComponentHost0(AppView<dynamic> parentView, int parentIndex) : super(import4.ViewType.host, {}, parentView, parentIndex, ChangeDetectionStrategy.CheckAlways); | ||
@override | ||
ComponentRef<import1.ChildComponent> build() { | ||
_compView_0 = new ViewChildComponent0(this, 0); | ||
rootEl = _compView_0.rootEl; | ||
_ChildComponent_0_5 = new import1.ChildComponent(); | ||
_compView_0.create(_ChildComponent_0_5, projectableNodes); | ||
init0(rootEl); | ||
return new ComponentRef(0, this, rootEl, _ChildComponent_0_5); | ||
} | ||
|
||
@override | ||
void detectChangesInternal() { | ||
_compView_0.detectChanges(); | ||
} | ||
|
||
@override | ||
void destroyInternal() { | ||
_compView_0?.destroy(); | ||
} | ||
} | ||
|
||
AppView<import1.ChildComponent> viewFactory_ChildComponentHost0(AppView<dynamic> parentView, int parentIndex) { | ||
return new _ViewChildComponentHost0(parentView, parentIndex); | ||
} | ||
|
||
const ComponentFactory<import1.ChildComponent> _ChildComponentNgFactory = const ComponentFactory('child-cmp', viewFactory_ChildComponentHost0, _ChildComponentMetadata); | ||
ComponentFactory<import1.ChildComponent> get ChildComponentNgFactory { | ||
return _ChildComponentNgFactory; | ||
} | ||
|
||
const _ParentComponentMetadata = const []; | ||
const _ChildComponentMetadata = const []; | ||
var _visited = false; | ||
void initReflector() { | ||
if (_visited) { | ||
return; | ||
} | ||
_visited = true; | ||
|
||
_ngRef.registerComponent(ParentComponent, ParentComponentNgFactory); | ||
_ngRef.registerComponent(ChildComponent, ChildComponentNgFactory); | ||
_ref0.initReflector(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this comment be removed as well?