90978: Explain dsBrowserPipe more thoroughly

This commit is contained in:
Yura Bondarenko
2022-05-05 10:50:24 +02:00
parent d69a02e6cc
commit c0f8dd078b
2 changed files with 12 additions and 2 deletions

View File

@@ -2,8 +2,19 @@ import { Inject, Pipe, PipeTransform, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
/**
* A pipe that only returns its intput when run in the browser.
* A pipe that only returns its input when run in the browser.
* Used to distinguish client-side rendered content from server-side rendered content.
*
* When used with attributes as in
* ```
* [attr.data-test]="'something' | dsBrowserOnly"
* ```
* the server-side rendered HTML will not contain the `data-test` attribute.
* When rendered client-side, the HTML will contain `data-test="something"`
*
* This can be useful for end-to-end testing elements that need JS (that isn't included in SSR HTML) to function:
* By depending on `dsBrowserOnly` attributes in tests we can make sure we wait
* until such components are fully interactive before trying to interact with them.
*/
@Pipe({
name: 'dsBrowserOnly'

View File

@@ -80,7 +80,6 @@ import { BreadcrumbsComponent } from './app/breadcrumbs/breadcrumbs.component';
import { FeedbackComponent } from './app/info/feedback/feedback.component';
import { CommunityListComponent } from './app/community-list-page/community-list/community-list.component';
// todo: optimize imports
const DECLARATIONS = [
FileSectionComponent,