build: remove usage of blacklist in benchmark tooling (#38926)

Removes the usage of blacklist in benchmark tooling, instead using more
specificity to indicate whether a row is collapsible.

PR Close #38926
This commit is contained in:
Joey Perrott 2020-09-21 14:06:31 -07:00 committed by Alex Rickabaugh
parent e459dc7c42
commit 914d7099ee
4 changed files with 17 additions and 18 deletions

View File

@ -45,10 +45,10 @@ export interface ExpandingRowHostBase {
handleRowSummaryClick(row: ExpandingRow): void; handleRowSummaryClick(row: ExpandingRow): void;
/** /**
* Check if element is blacklisted. Blacklisted elements will not collapse an * Check if element is collapsible. Elements marked as uncollapsible will not collapse an
* open row when clicked. * open row when clicked.
*/ */
isBlacklisted(element: HTMLElement|null): boolean; isCollapsible(element: HTMLElement|null): boolean;
/** /**
* Handles caption element click on a cfc-expanding-row component. Note * Handles caption element click on a cfc-expanding-row component. Note
@ -247,16 +247,15 @@ export class ExpandingRow {
* notify click on its host element. Note that caption is only shown when * notify click on its host element. Note that caption is only shown when
* the row is expanded. Hence this will collapse this row and put the focus * the row is expanded. Hence this will collapse this row and put the focus
* on it. * on it.
* If a blacklisted element exists in the caption, clicking that element will * If an uncollapsible element exists in the caption, clicking that element will
* not trigger the row collapse. * not trigger the row collapse.
*/ */
handleCaptionClick(event: MouseEvent): void { handleCaptionClick(event: MouseEvent): void {
if (this.expandingRowHost.isBlacklisted(event.target as {} as HTMLElement)) { if (this.expandingRowHost.isCollapsible(event.target as {} as HTMLElement)) {
return; this.expandingRowHost.handleRowCaptionClick(this);
this.collapse();
this.focus();
} }
this.expandingRowHost.handleRowCaptionClick(this);
this.collapse();
this.focus();
} }
/** /**

View File

@ -315,18 +315,18 @@ export class ExpandingRowHost implements AfterViewInit, OnDestroy, ExpandingRowH
} }
/** /**
* Check if element is blacklisted. Blacklisted elements will not collapse an * Check if element is collapsible. Elements marked as uncollapsible will not collapse an
* open row when clicked. * open row when clicked.
*/ */
isBlacklisted(element: HTMLElement|null): boolean { isCollapsible(element: HTMLElement|null): boolean {
const clickRoot = this.getClickRootElement(); const clickRoot = this.getClickRootElement();
while (element && element !== clickRoot) { while (element && element !== clickRoot) {
if (element.hasAttribute('cfcexpandingrowblacklist')) { if (element.hasAttribute('cfcUncollapsible')) {
return true; return false;
} }
element = element.parentElement; element = element.parentElement;
} }
return false; return true;
} }
/** /**

View File

@ -10,11 +10,11 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {ExpandingRow} from './expanding_row'; import {ExpandingRow} from './expanding_row';
import {ExpandingRowBlacklist} from './expanding_row_blacklist';
import {ExpandingRowDetailsCaption} from './expanding_row_details_caption'; import {ExpandingRowDetailsCaption} from './expanding_row_details_caption';
import {ExpandingRowDetailsContent} from './expanding_row_details_content'; import {ExpandingRowDetailsContent} from './expanding_row_details_content';
import {ExpandingRowHost} from './expanding_row_host'; import {ExpandingRowHost} from './expanding_row_host';
import {ExpandingRowSummary} from './expanding_row_summary'; import {ExpandingRowSummary} from './expanding_row_summary';
import {ExpandingRowUncollapsible} from './expanding_row_uncollapsible';
/** The main module for the cfc-expanding-row component. */ /** The main module for the cfc-expanding-row component. */
@NgModule({ @NgModule({
@ -24,7 +24,7 @@ import {ExpandingRowSummary} from './expanding_row_summary';
ExpandingRowDetailsContent, ExpandingRowDetailsContent,
ExpandingRowHost, ExpandingRowHost,
ExpandingRowSummary, ExpandingRowSummary,
ExpandingRowBlacklist, ExpandingRowUncollapsible,
], ],
exports: [ exports: [
ExpandingRow, ExpandingRow,
@ -32,7 +32,7 @@ import {ExpandingRowSummary} from './expanding_row_summary';
ExpandingRowDetailsContent, ExpandingRowDetailsContent,
ExpandingRowHost, ExpandingRowHost,
ExpandingRowSummary, ExpandingRowSummary,
ExpandingRowBlacklist, ExpandingRowUncollapsible,
], ],
imports: [ imports: [
CommonModule, CommonModule,

View File

@ -14,7 +14,7 @@ import {Directive} from '@angular/core';
* expanded row * expanded row
*/ */
@Directive({ @Directive({
selector: '[cfcExpandingRowBlacklist]', selector: '[cfcUncollapsible]',
}) })
export class ExpandingRowBlacklist { export class ExpandingRowUncollapsible {
} }