Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions _tests/test/compiler/ast_directive_normalizer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ void main() {
type: CompileTypeMetadata(name: 'A', moduleUrl: 'package:a/a.dart'),
template: CompileTemplateMetadata(
template: '',
encapsulation: ViewEncapsulation.Emulated,
encapsulation: ViewEncapsulation.emulated,
),
);
metadata = await normalizer.normalizeDirective(metadata);
expect(metadata.template.encapsulation, ViewEncapsulation.None);
expect(metadata.template.encapsulation, ViewEncapsulation.none);
});

test('should resolve inline stylesheets', () async {
Expand Down Expand Up @@ -205,7 +205,7 @@ void main() {
),
);
metadata = await normalizer.normalizeDirective(metadata);
expect(metadata.template.encapsulation, ViewEncapsulation.Emulated);
expect(metadata.template.encapsulation, ViewEncapsulation.emulated);
expect(
metadata.template.styles,
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
@Component(
selector: 'test',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {}
""");
Expand All @@ -39,7 +39,7 @@ void main() {
""", errors: [
allOf([
contains(
'Only supported on components that use "OnPush" change detection',
'Only supported on components that use "onPush" change detection',
),
containsSourceLocation(4, 9),
]),
Expand All @@ -57,7 +57,7 @@ void main() {
""", errors: [
allOf([
contains(
'Only supported on components that use "OnPush" change detection',
'Only supported on components that use "onPush" change detection',
),
containsSourceLocation(4, 9),
]),
Expand Down
20 changes: 10 additions & 10 deletions _tests/test/compiler_integration/on_push_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:ngcompiler/v2/context.dart';
void main() {
CompileContext.overrideForTesting();

test('emits warning for Default component in OnPush template', () async {
test('emits warning for Default component in onPush template', () async {
await compilesExpecting("""
import '$ngImport';
Expand All @@ -24,22 +24,22 @@ void main() {
<default></default>
</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
directives: [DefaultComponent],
)
class TestComponent {}
""", warnings: [
allOf([
contains('<default>'),
contains(
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.OnPush"',
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.onPush"',
),
]),
]);
});

group('@skipOnPushValidation', () {
test('silences warning for Default component in OnPush template', () async {
test('silences warning for Default component in onPush template', () async {
await compilesNormally("""
import '$ngImport';
Expand All @@ -56,7 +56,7 @@ void main() {
<default @skipOnPushValidation></default>
</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
directives: [DefaultComponent],
)
class TestComponent {}
Expand All @@ -73,7 +73,7 @@ void main() {
template: '''
<div @skipOnPushValidation></div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TestComponent {}
""", errors: [
Expand All @@ -91,7 +91,7 @@ void main() {
@Component(
selector: 'on-push',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {}
Expand All @@ -101,15 +101,15 @@ void main() {
<on-push @skipOnPushValidation></on-push>
''',
directives: [OnPushComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TestComponent {}
""", errors: [
allOf([
contains('@skipOnPushValidation'),
contains(
'Can only be applied to a component using '
'"ChangeDetectionStrategy.Default"',
'"ChangeDetectionStrategy.default_"',
),
]),
]);
Expand Down Expand Up @@ -138,7 +138,7 @@ void main() {
contains('@skipOnPushValidation'),
contains(
'Can only be used in the template of a component using '
'"ChangeDetectionStrategy.OnPush"',
'"ChangeDetectionStrategy.onPush"',
),
]),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DefaultComponent {
@Component(
selector: 'on-push-container',
template: '<template #container></template>',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushContainerComponent {
@Input()
Expand Down Expand Up @@ -142,7 +142,7 @@ class LoadInOnPush {
</on-push-container>
''',
directives: [OnPushContainerComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushAncestorComponent {
@Input()
Expand Down Expand Up @@ -170,7 +170,7 @@ class LoadInOnPushDescendant {
</ng-container>
''',
directives: [NgIf],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushEmbeddedContainerComponent {
OnPushEmbeddedContainerComponent(this._changeDetectorRef, this._ngZone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {

setUp(() => logs = []);

test('ChangeDetectionStrategy.Detached should behave strangely', () async {
test('ChangeDetectionStrategy.detached should behave strangely', () async {
final testBed = NgTestBed<TestDetachedViaStrategy>(
ng.createTestDetachedViaStrategyFactory(),
);
Expand Down Expand Up @@ -214,7 +214,7 @@ class Logger implements OnInit, AfterChanges, AfterViewInit, AfterContentInit {
</span>
''',
// ignore: deprecated_member_use
changeDetection: ChangeDetectionStrategy.Detached,
changeDetection: ChangeDetectionStrategy.detached,
)
class DetachedViaStrategy extends Logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void main() {
@Component(
selector: 'child',
template: '{{value}}',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class Child {
var value = '';
Expand Down Expand Up @@ -245,7 +245,7 @@ abstract class HasValue {
providers: [
ExistingProvider(HasValue, ChildWithExistingProvider),
],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class ChildWithExistingProvider implements HasValue {
@override
Expand Down
2 changes: 1 addition & 1 deletion _tests/test/core/change_detection/mark_for_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class UsesOnPushComponent {
directives: [
NgIf,
],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {
final ChangeDetectorRef _changeDetector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ void main() {
// When these parents are the same, embedded views are well behaved.
//
// However, when an embedded view is hosted in the view container of another
// OnPush view, it may cease to correctly receive updates from its
// onPush view, it may cease to correctly receive updates from its
// `<template>` parent.
//
// When embedded within an OnPush component, an embedded view is only change
// When embedded within an onPush component, an embedded view is only change
// detected when that parent is marked to be checked. This poses a problem for
// embedded views with expressions bound to their `<template>` parent. When
// such an embedded view is hosted in the view container of another OnPush
// such an embedded view is hosted in the view container of another onPush
// component, there's currently no mechanism in the framework that marks that
// component to be checked when the `<template>` parent receives a change that
// could invalidate a binding within the `<template>`.
Expand Down Expand Up @@ -65,7 +65,7 @@ void main() {

// The above change only causes the template producer and its child nested
// views to be updated. Any templates that originated within its view that
// are embedded in a foreign OnPush view don't receive these changes.
// are embedded in a foreign onPush view don't receive these changes.
expect(
component.templateConsumer!.text,
contains('Hello template!'),
Expand All @@ -77,7 +77,7 @@ void main() {
});

// The above change that was previously expected is now observed in the
// template embedded in a foreign view container with an OnPush parent.
// template embedded in a foreign view container with an onPush parent.
expect(
component.templateConsumer!.text,
contains('Hello template!'),
Expand Down Expand Up @@ -124,7 +124,7 @@ class TestComponent {
template: '''
<template #template>{{templateText}}</template>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
exportAs: 'templateProducer',
)
class TemplateProducerComponent implements OnInit {
Expand All @@ -149,7 +149,7 @@ class TemplateProducerComponent implements OnInit {
<template #container></template>
<div>{{text}}</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TemplateConsumerComponent implements OnInit {
@ViewChild('container', read: ViewContainerRef)
Expand Down
2 changes: 1 addition & 1 deletion _tests/test/core/linker/component_loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class DynamicComp extends Lifecycles {
@Component(
selector: 'dynamic-comp',
template: 'Dynamic{{input}}',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class DynamicOnPushComp extends Lifecycles {
DynamicOnPushComp(super.log);
Expand Down
8 changes: 4 additions & 4 deletions _tests/test/core/linker/integration/on_push_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void main() {

@Component(
selector: 'push-cmp-with-ref',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
template: '{{field}}',
)
class PushCmpWithRef {
Expand Down Expand Up @@ -150,15 +150,15 @@ class ManualCheckLoadedComponent {
@Component(
selector: 'event-cmp',
template: '<div (click)="noop()"></div>',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class EventCmp {
void noop() {}
}

@Component(
selector: 'push-cmp',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
template: '{{field}}<div (click)="noop()"></div><div *ngIf="true" '
'(click)="noop()"></div><event-cmp></event-cmp>',
directives: [EventCmp, NgIf],
Expand Down Expand Up @@ -203,7 +203,7 @@ class PushCmpWithRefHostComponent {

@Component(
selector: 'push-cmp-with-async',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
template: r'{{$pipe.async(field)}}',
pipes: [AsyncPipe],
)
Expand Down
4 changes: 2 additions & 2 deletions _tests/test/core/view/projection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class ManualViewportDirective {
selector: 'container-with-style-emu',
template: '<div class="blueStyle"></div>',
styles: ['.blueStyle { color: blue}'],
encapsulation: ViewEncapsulation.Emulated,
encapsulation: ViewEncapsulation.emulated,
directives: [SimpleComponent],
)
class ContainerWithStyleEmulated {}
Expand All @@ -290,7 +290,7 @@ class ContainerWithStyleEmulated {}
selector: 'container-with-style-not-emu',
template: '<div class="redStyle"></div>',
styles: ['.redStyle { color: red}'],
encapsulation: ViewEncapsulation.None,
encapsulation: ViewEncapsulation.none,
directives: [SimpleComponent],
)
class ContainerWithStyleNotEmulated {}
Expand Down
4 changes: 2 additions & 2 deletions ngcompiler/lib/v1/src/angular_compiler/cli/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ abstract class Messages {
return buffer.toString();
}

/// What message should be used for OnPush compatibility warnings.
/// What message should be used for onPush compatibility warnings.
String warningForOnPushCompatibility(String name) {
return ''
'"$name" doesn\'t use "ChangeDetectionStrategy.OnPush", but '
'"$name" doesn\'t use "ChangeDetectionStrategy.onPush", but '
'is used by a component that does. This is unsupported and unlikely '
'to work as expected.';
}
Expand Down
4 changes: 2 additions & 2 deletions ngcompiler/lib/v1/src/compiler/angular_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class AngularCompiler {
NormalizedComponentWithViewDirectives componentWithDirs,
) {
switch (componentWithDirs.component.template!.encapsulation) {
case ViewEncapsulation.Emulated:
case ViewEncapsulation.emulated:
return ir.ViewEncapsulation.emulated;
case ViewEncapsulation.None:
case ViewEncapsulation.none:
return ir.ViewEncapsulation.none;
default:
throw ArgumentError.value(
Expand Down
4 changes: 2 additions & 2 deletions ngcompiler/lib/v1/src/compiler/ast_directive_normalizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ class AstDirectiveNormalizer {

// Optimization: Turn off encapsulation when there are no styles to apply.
var encapsulation = templateMeta.encapsulation;
if (encapsulation == ViewEncapsulation.Emulated &&
if (encapsulation == ViewEncapsulation.emulated &&
templateMeta.styles.isEmpty &&
allExternalStyles.isEmpty) {
encapsulation = ViewEncapsulation.None;
encapsulation = ViewEncapsulation.none;
}

return CompileTemplateMetadata(
Expand Down
Loading