Skip to content

Commit fd53473

Browse files
committed
stop using ng-content
1 parent cafc66c commit fd53473

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

src/cdk/testing/tests/harnesses/main-component-harness.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export class MainComponentHarness extends ComponentHarness {
8282
readonly missingElementsAndHarnesses =
8383
this.locatorFor('.not-found', SubComponentHarness.with({title: /not found/}));
8484
readonly shadows = this.locatorForAll('.in-the-shadows');
85-
readonly deepShadow = this.locatorFor('.in-the-shadows + test-shadow-boundary > .in-the-shadows');
85+
readonly deepShadow = this.locatorFor(
86+
'.in-the-shadows + test-sub-shadow-boundary > .in-the-shadows');
8687

8788
private _testTools = this.locatorFor(SubComponentHarness);
8889

src/cdk/testing/tests/test-components-module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {CommonModule} from '@angular/common';
1010
import {NgModule} from '@angular/core';
1111
import {FormsModule} from '@angular/forms';
1212
import {TestMainComponent} from './test-main-component';
13-
import {TestShadowBoundary} from './test-shadow-boundary';
13+
import {TestShadowBoundary, TestSubShadowBoundary} from './test-shadow-boundary';
1414
import {TestSubComponent} from './test-sub-component';
1515

1616
@NgModule({
1717
imports: [CommonModule, FormsModule],
18-
declarations: [TestMainComponent, TestSubComponent, TestShadowBoundary],
19-
exports: [TestMainComponent, TestSubComponent, TestShadowBoundary]
18+
declarations: [TestMainComponent, TestSubComponent, TestShadowBoundary, TestSubShadowBoundary],
19+
exports: [TestMainComponent, TestSubComponent, TestShadowBoundary, TestSubShadowBoundary]
2020
})
2121
export class TestComponentsModule {}

src/cdk/testing/tests/test-main-component.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,4 @@ <h1 style="height: 100px; width: 200px;">Main Component</h1>
3232
</button>
3333
<span id="task-state-result" #taskStateResult></span>
3434
</div>
35-
<test-shadow-boundary *ngIf="_shadowDomSupported">
36-
<div class="in-the-shadows">Shadow 1</div>
37-
<test-shadow-boundary>
38-
<div class="in-the-shadows">Shadow 2</div>
39-
</test-shadow-boundary>
40-
</test-shadow-boundary>
35+
<test-shadow-boundary *ngIf="_shadowDomSupported"></test-shadow-boundary>

src/cdk/testing/tests/test-shadow-boundary.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
1010

1111
@Component({
1212
selector: 'test-shadow-boundary',
13-
template: '<ng-content></ng-content>',
13+
template: `
14+
<div class="in-the-shadows">Shadow 1</div>
15+
<test-sub-shadow-boundary></test-sub-shadow-boundary>
16+
`,
1417
changeDetection: ChangeDetectionStrategy.OnPush,
1518
// tslint:disable-next-line:validate-decorators
1619
encapsulation: ViewEncapsulation.ShadowDom,
1720
})
1821
export class TestShadowBoundary {}
22+
23+
@Component({
24+
selector: 'test-sub-shadow-boundary',
25+
template: '<div class="in-the-shadows">Shadow 2</div>',
26+
changeDetection: ChangeDetectionStrategy.OnPush,
27+
// tslint:disable-next-line:validate-decorators
28+
encapsulation: ViewEncapsulation.ShadowDom,
29+
})
30+
export class TestSubShadowBoundary {}

src/cdk/testing/tests/testbed.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {_supportsShadowDom, Platform} from '@angular/cdk/platform';
1+
import {_supportsShadowDom} from '@angular/cdk/platform';
22
import {
33
ComponentHarness,
44
ComponentHarnessConstructor,
@@ -503,9 +503,7 @@ describe('TestbedHarnessEnvironment', () => {
503503
});
504504
});
505505

506-
const platform = new Platform();
507-
// Safari only has parial shadow DOM support (https://caniuse.com/#feat=shadowdomv1)
508-
if (_supportsShadowDom() && !platform.SAFARI) {
506+
if (_supportsShadowDom()) {
509507
describe('shadow DOM interaction', () => {
510508
it('should not pierce shadow boundary by default', async () => {
511509
const harness = await TestbedHarnessEnvironment

0 commit comments

Comments
 (0)