Skip to content

Commit 4a1c12c

Browse files
crisbetoatscott
authored andcommitted
feat(core): remove ViewEncapsulation.Native (#38882)
Removes `ViewEncapsulation.Native` which has been deprecated for several major versions. BREAKING CHANGES: * `ViewEncapsulation.Native` has been removed. Use `ViewEncapsulation.ShadowDom` instead. Existing usages will be updated automatically by `ng update`. PR Close #38882
1 parent 0e733f3 commit 4a1c12c

File tree

25 files changed

+77
-91
lines changed

25 files changed

+77
-91
lines changed

aio/content/examples/component-styles/src/app/quest-summary.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { Component, ViewEncapsulation } from '@angular/core';
1313
export class QuestSummaryComponent { }
1414
// #enddocregion
1515
/*
16-
// #docregion encapsulation.native
16+
// #docregion encapsulation.shadow
1717
// warning: few browsers support shadow DOM encapsulation at this time
18-
encapsulation: ViewEncapsulation.Native
19-
// #enddocregion encapsulation.native
18+
encapsulation: ViewEncapsulation.ShadowDom
19+
// #enddocregion encapsulation.shadow
2020
*/

aio/content/guide/deprecations.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ v9 - v12
4141
| `@angular/core` | [`DefaultIterableDiffer`](#core) | <!--v7--> v11 |
4242
| `@angular/core` | [`ReflectiveKey`](#core) | <!--v8--> v11 |
4343
| `@angular/core` | [`RenderComponentType`](#core) | <!--v7--> v11 |
44-
| `@angular/core` | [`ViewEncapsulation.Native`](#core) | <!--v6--> v11 |
4544
| `@angular/core` | [`WrappedValue`](#core) | <!--v10--> v12 |
4645
| `@angular/forms` | [`ngModel` with reactive forms](#ngmodel-reactive) | <!--v6--> v11 |
4746
| `@angular/router` | [`preserveQueryParams`](#router) | <!--v7--> v11 |
@@ -89,7 +88,6 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
8988
| [`DefaultIterableDiffer`](api/core/DefaultIterableDiffer) | n/a | v4 | Not part of public API. |
9089
| [`ReflectiveInjector`](api/core/ReflectiveInjector) | [`Injector.create`](api/core/Injector#create) | v5 | See [`ReflectiveInjector`](#reflectiveinjector) |
9190
| [`ReflectiveKey`](api/core/ReflectiveKey) | none | v5 | none |
92-
| [`ViewEncapsulation.Native`](api/core/ViewEncapsulation#Native) | [`ViewEncapsulation.ShadowDom`](api/core/ViewEncapsulation#ShadowDom) | v6 | Use the native encapsulation mechanism of the renderer. See [view.ts](https://github.com/angular/angular/blob/3e992e18ebf51d6036818f26c3d77b52d3ec48eb/packages/core/src/metadata/view.ts#L32).
9391
| [`defineInjectable`](api/core/defineInjectable) | `ɵɵdefineInjectable` | v8 | Used only in generated code. No source code should depend on this API. |
9492
| [`entryComponents`](api/core/NgModule#entryComponents) | none | v9 | See [`entryComponents`](#entryComponents) |
9593
| [`ANALYZE_FOR_ENTRY_COMPONENTS`](api/core/ANALYZE_FOR_ENTRY_COMPONENTS) | none | v9 | See [`ANALYZE_FOR_ENTRY_COMPONENTS`](#entryComponents) |

aio/content/guide/view-encapsulation.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Choose from the following modes:
1313
to attach a shadow DOM to the component's host element, and then puts the component
1414
view inside that shadow DOM. The component's styles are included within the shadow DOM.
1515

16-
* `Native` view encapsulation uses a now deprecated version of the browser's native shadow DOM implementation - [learn about the changes](https://hayato.io/2016/shadowdomv1/).
17-
1816
* `Emulated` view encapsulation (the default) emulates the behavior of shadow DOM by preprocessing
1917
(and renaming) the CSS code to effectively scope the CSS to the component's view.
2018
For details, see [Inspecting generated CSS](guide/view-encapsulation#inspect-generated-css) below.
@@ -26,7 +24,7 @@ Choose from the following modes:
2624

2725
To set the components encapsulation mode, use the `encapsulation` property in the component metadata:
2826

29-
<code-example path="component-styles/src/app/quest-summary.component.ts" region="encapsulation.native" header="src/app/quest-summary.component.ts"></code-example>
27+
<code-example path="component-styles/src/app/quest-summary.component.ts" region="encapsulation.shadow" header="src/app/quest-summary.component.ts"></code-example>
3028

3129
`ShadowDom` view encapsulation only works on browsers that have native support
3230
for shadow DOM (see [Shadow DOM v1](https://caniuse.com/#feat=shadowdomv1) on the
@@ -80,4 +78,4 @@ by the generated component styles, which are in the `<head>` section of the DOM:
8078

8179
These styles are post-processed so that each selector is augmented
8280
with `_nghost` or `_ngcontent` attribute selectors.
83-
These extra selectors enable the scoping rules described in this page.
81+
These extra selectors enable the scoping rules described in this page.

aio/src/app/layout/doc-viewer/doc-viewer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const initialDocViewerContent = initialDocViewerElement ? initialDocViewerElemen
2121
selector: 'aio-doc-viewer',
2222
template: ''
2323
// TODO(robwormald): shadow DOM and emulated don't work here (?!)
24-
// encapsulation: ViewEncapsulation.Native
24+
// encapsulation: ViewEncapsulation.ShadowDom
2525
})
2626
export class DocViewerComponent implements OnDestroy {
2727
// Enable/Disable view transition animations.

goldens/public-api/core/core.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,6 @@ export declare abstract class ViewContainerRef {
10321032

10331033
export declare enum ViewEncapsulation {
10341034
Emulated = 0,
1035-
Native = 1,
10361035
None = 2,
10371036
ShadowDom = 3
10381037
}

goldens/size-tracking/integration-payloads.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"master": {
3131
"uncompressed": {
3232
"runtime-es2015": 1485,
33-
"main-es2015": 134891,
33+
"main-es2015": 135003,
3434
"polyfills-es2015": 37248
3535
}
3636
}

packages/bazel/src/schematics/ng-new/schema.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export declare enum Style {
107107
*/
108108
export declare enum ViewEncapsulation {
109109
Emulated = 'Emulated',
110-
Native = 'Native',
111110
None = 'None',
112111
ShadowDom = 'ShadowDom'
113112
}

packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ describe('compiler compliance: styling', () => {
7272
expectEmit(result.source, template, 'Incorrect template');
7373
});
7474

75-
it('should pass in the component metadata styles into the component definition but skip shimming when style encapsulation is set to native',
75+
it('should pass in the component metadata styles into the component definition but skip shimming when style encapsulation is set to shadow dom',
7676
() => {
7777
const files = {
7878
app: {
7979
'spec.ts': `
8080
import {Component, NgModule, ViewEncapsulation} from '@angular/core';
8181
8282
@Component({
83-
encapsulation: ViewEncapsulation.Native,
83+
encapsulation: ViewEncapsulation.ShadowDom,
8484
selector: "my-component",
8585
styles: ["div.cool { color: blue; }", ":host.nice p { color: gold; }"],
8686
template: "..."
@@ -98,7 +98,7 @@ describe('compiler compliance: styling', () => {
9898
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
9999
100100
styles: ["div.cool { color: blue; }", ":host.nice p { color: gold; }"],
101-
encapsulation: 1
101+
encapsulation: 3
102102
})
103103
`;
104104
const result = compile(files, angularFiles);

packages/compiler-cli/test/ngtsc/fake_core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export type ɵɵPipeDefWithMeta<PipeT, NameT> = any;
7777

7878
export enum ViewEncapsulation {
7979
Emulated = 0,
80-
Native = 1,
80+
// Historically the 1 value was for `Native` encapsulation which has been removed as of v11.
8181
None = 2,
8282
ShadowDom = 3
8383
}

packages/compiler/src/compiler_facade_interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export interface R3FactoryDefMetadataFacade {
173173

174174
export enum ViewEncapsulation {
175175
Emulated = 0,
176-
Native = 1,
176+
// Historically the 1 value was for `Native` encapsulation which has been removed as of v11.
177177
None = 2,
178178
ShadowDom = 3
179179
}

0 commit comments

Comments
 (0)