Skip to content

Commit beeb30b

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Improve ergonomics for importing Lit functions.
Instead of the cumbersome ``` import * as Lit from '../../ui/lit/lit.js'; // ... const {render, html} = Lit; ``` you can now simply use ``` import {render, html} from '../../ui/lit/lit.js'; ``` directly. Bug: 301364727 Change-Id: If3441bd120dbce8902caab17bc4bf1703ed77270 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6216537 Commit-Queue: Nikolay Vitkov <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]>
1 parent 41c6911 commit beeb30b

File tree

61 files changed

+129
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+129
-236
lines changed

front_end/entrypoints/main/MainImpl.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
*/
3434

35-
import '../../ui/legacy/legacy.js';
36-
3735
import * as Common from '../../core/common/common.js';
3836
import * as Host from '../../core/host/host.js';
3937
import * as i18n from '../../core/i18n/i18n.js';
@@ -57,13 +55,11 @@ import * as IconButton from '../../ui/components/icon_button/icon_button.js';
5755
import * as Components from '../../ui/legacy/components/utils/utils.js';
5856
import * as UI from '../../ui/legacy/legacy.js';
5957
import * as ThemeSupport from '../../ui/legacy/theme_support/theme_support.js';
60-
import * as Lit from '../../ui/lit/lit.js';
58+
import {html, render} from '../../ui/lit/lit.js';
6159
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
6260

6361
import {ExecutionContextSelector} from './ExecutionContextSelector.js';
6462

65-
const {html, render} = Lit;
66-
6763
const UIStrings = {
6864
/**
6965
*@description Title of item in main

front_end/panels/application/preloading/PreloadingView.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ import type * as SplitView from '../../../ui/components/split_view/split_view.js
1717
// eslint-disable-next-line rulesdir/es-modules-import
1818
import emptyWidgetStyles from '../../../ui/legacy/emptyWidget.css.js';
1919
import * as UI from '../../../ui/legacy/legacy.js';
20-
import * as Lit from '../../../ui/lit/lit.js';
20+
import {html, render} from '../../../ui/lit/lit.js';
2121
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
2222

2323
import * as PreloadingComponents from './components/components.js';
2424
import type * as PreloadingHelper from './helper/helper.js';
2525
import preloadingViewStyles from './preloadingView.css.js';
2626
import preloadingViewDropDownStyles from './preloadingViewDropDown.css.js';
2727

28-
const {html} = Lit;
29-
3028
const UIStrings = {
3129
/**
3230
*@description DropDown title for filtering preloading attempts by rule set
@@ -228,7 +226,7 @@ export class PreloadingRuleSetView extends UI.Widget.VBox {
228226
};
229227

230228
// clang-format off
231-
Lit.render(
229+
render(
232230
html`
233231
<devtools-split-view .horizontal=${true} style="--min-sidebar-size: max(100vh-200px, 0px)">
234232
<div slot="main" class="overflow-auto" style="height: 100%">
@@ -377,7 +375,7 @@ export class PreloadingAttemptView extends UI.Widget.VBox {
377375
toolbar.appendToolbarItem(this.ruleSetSelector.item());
378376

379377
this.preloadingGrid.addEventListener('select', this.onPreloadingGridCellFocused.bind(this));
380-
Lit.render(
378+
render(
381379
html`
382380
<devtools-split-view .horizontal=${true} style="--min-sidebar-size: 0px">
383381
<div slot="main" class="overflow-auto" style="height: 100%">

front_end/panels/css_overview/components/CSSOverviewStartView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '../../../ui/components/panel_introduction_steps/panel_introduction_steps
88
import * as i18n from '../../../core/i18n/i18n.js';
99
import type * as Platform from '../../../core/platform/platform.js';
1010
import * as Buttons from '../../../ui/components/buttons/buttons.js';
11-
import * as Lit from '../../../ui/lit/lit.js';
11+
import {html, render} from '../../../ui/lit/lit.js';
1212

1313
import cssOverviewStartViewStylesRaw from './cssOverviewStartView.css.js';
1414

@@ -46,8 +46,6 @@ const UIStrings = {
4646
const str_ = i18n.i18n.registerUIStrings('panels/css_overview/components/CSSOverviewStartView.ts', UIStrings);
4747
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
4848

49-
const {render, html} = Lit;
50-
5149
const FEEDBACK_LINK = 'https://g.co/devtools/css-overview-feedback' as Platform.DevToolsPath.UrlString;
5250
const DOC_LINK = 'https://developer.chrome.com/docs/devtools/css-overview' as Platform.DevToolsPath.UrlString;
5351
export class OverviewStartRequestedEvent extends Event {

front_end/panels/developer_resources/DeveloperResourcesListView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import * as SDK from '../../core/sdk/sdk.js';
1111
import type * as Protocol from '../../generated/protocol.js';
1212
import * as TextUtils from '../../models/text_utils/text_utils.js';
1313
import * as UI from '../../ui/legacy/legacy.js';
14-
import * as Lit from '../../ui/lit/lit.js';
14+
import {html, nothing, render} from '../../ui/lit/lit.js';
1515

1616
import developerResourcesListViewStyles from './developerResourcesListView.css.js';
1717

18-
const {render, html, nothing} = Lit;
19-
2018
const UIStrings = {
2119
/**
2220
*@description Text for the status of something

front_end/panels/elements/components/AccessibilityTreeNode.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import * as i18n from '../../../core/i18n/i18n.js';
66
import * as Platform from '../../../core/platform/platform.js';
77
import * as Protocol from '../../../generated/protocol.js';
88
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
9-
import * as Lit from '../../../ui/lit/lit.js';
9+
import {html, nothing, render} from '../../../ui/lit/lit.js';
1010

1111
import accessibilityTreeNodeStylesRaw from './accessibilityTreeNode.css.js';
1212

1313
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
1414
const accessibilityTreeNodeStyles = new CSSStyleSheet();
1515
accessibilityTreeNodeStyles.replaceSync(accessibilityTreeNodeStylesRaw.cssContent);
1616

17-
const {html} = Lit;
18-
1917
const UIStrings = {
2018
/**
2119
*@description Ignored node element text content in Accessibility Tree View of the Elements panel
@@ -85,12 +83,12 @@ export class AccessibilityTreeNode extends HTMLElement {
8583
({name, value}) => isPrintable(value.type) ?
8684
html` <span class='attribute-name'>${name}</span>:&nbsp;<span class='attribute-value'>${
8785
value.value}</span>` :
88-
Lit.nothing);
86+
nothing);
8987
const content =
9088
this.#ignored ? html`<span>${i18nString(UIStrings.ignored)}</span>` : html`${role}&nbsp;${name}${properties}`;
9189
await RenderCoordinator.write(`Accessibility node ${this.#id} render`, () => {
9290
// clang-format off
93-
Lit.render(
91+
render(
9492
html`<div class='container'>${content}</div>`,
9593
this.#shadow,
9694
{host: this});

front_end/panels/elements/components/CSSHintDetailsView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '../../../ui/legacy/legacy.js';
66

77
import * as i18n from '../../../core/i18n/i18n.js';
8-
import * as Lit from '../../../ui/lit/lit.js';
8+
import {Directives, html, render} from '../../../ui/lit/lit.js';
99

1010
import cssHintDetailsViewStylesRaw from './cssHintDetailsView.css.js';
1111

@@ -22,8 +22,6 @@ const UIStrings = {
2222
const str_ = i18n.i18n.registerUIStrings('panels/elements/components/CSSHintDetailsView.ts', UIStrings);
2323
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
2424

25-
const {render, html, Directives} = Lit;
26-
2725
interface Hint {
2826
getMessage(): string;
2927
getPossibleFixMessage(): string|null;

front_end/panels/elements/components/CSSPropertyDocsView.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../../../ui/legacy/legacy.js';
77
import * as Common from '../../../core/common/common.js';
88
import * as i18n from '../../../core/i18n/i18n.js';
99
import * as Input from '../../../ui/components/input/input.js';
10-
import * as Lit from '../../../ui/lit/lit.js';
10+
import {html, nothing, render} from '../../../ui/lit/lit.js';
1111
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1212

1313
import CSSPropertyDocsViewStylesRaw from './cssPropertyDocsView.css.js';
@@ -29,8 +29,6 @@ const UIStrings = {
2929
const str_ = i18n.i18n.registerUIStrings('panels/elements/components/CSSPropertyDocsView.ts', UIStrings);
3030
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
3131

32-
const {render, html} = Lit;
33-
3432
interface CSSProperty {
3533
name: string;
3634
description?: string;
@@ -70,7 +68,7 @@ export class CSSPropertyDocsView extends HTMLElement {
7068
<div id="description">
7169
${description}
7270
</div>
73-
` : Lit.nothing}
71+
` : nothing}
7472
${link ? html`
7573
<div class="docs-popup-section footer">
7674
<x-link
@@ -85,7 +83,7 @@ export class CSSPropertyDocsView extends HTMLElement {
8583
${i18nString(UIStrings.dontShow)}
8684
</label>
8785
</div>
88-
` : Lit.nothing}
86+
` : nothing}
8987
</div>
9088
`, this.#shadow, {
9189
host: this,

front_end/panels/elements/components/ComputedStyleProperty.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import * as Lit from '../../../ui/lit/lit.js';
5+
import {html, render} from '../../../ui/lit/lit.js';
66
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
77

88
import computedStylePropertyStylesRaw from './computedStyleProperty.css.js';
@@ -11,8 +11,6 @@ import computedStylePropertyStylesRaw from './computedStyleProperty.css.js';
1111
const computedStylePropertyStyles = new CSSStyleSheet();
1212
computedStylePropertyStyles.replaceSync(computedStylePropertyStylesRaw.cssContent);
1313

14-
const {render, html} = Lit;
15-
1614
export class NavigateToSourceEvent extends Event {
1715
static readonly eventName = 'onnavigatetosource';
1816
constructor() {

front_end/panels/elements/components/ComputedStyleTrace.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
// found in the LICENSE file.
44

55
import * as UI from '../../../ui/legacy/legacy.js';
6-
import * as Lit from '../../../ui/lit/lit.js';
6+
import {html, render} from '../../../ui/lit/lit.js';
77

88
import computedStyleTraceStylesRaw from './computedStyleTrace.css.js';
99

1010
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
1111
const computedStyleTraceStyles = new CSSStyleSheet();
1212
computedStyleTraceStyles.replaceSync(computedStyleTraceStylesRaw.cssContent);
1313

14-
const {render, html} = Lit;
15-
1614
export interface ComputedStyleTraceData {
1715
selector: string;
1816
active: boolean;

front_end/panels/elements/components/ElementsTreeExpandButton.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '../../../ui/components/icon_button/icon_button.js';
66

77
import * as i18n from '../../../core/i18n/i18n.js';
8-
import * as Lit from '../../../ui/lit/lit.js';
8+
import {html, render} from '../../../ui/lit/lit.js';
99
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1010

1111
import elementsTreeExpandButtonStylesRaw from './elementsTreeExpandButton.css.js';
@@ -14,8 +14,6 @@ import elementsTreeExpandButtonStylesRaw from './elementsTreeExpandButton.css.js
1414
const elementsTreeExpandButtonStyles = new CSSStyleSheet();
1515
elementsTreeExpandButtonStyles.replaceSync(elementsTreeExpandButtonStylesRaw.cssContent);
1616

17-
const {html} = Lit;
18-
1917
const UIStrings = {
2018
/**
2119
*@description Aria label for a button expanding collapsed subtree
@@ -50,7 +48,7 @@ export class ElementsTreeExpandButton extends HTMLElement {
5048
// clang-format off
5149
// This button's innerText will be tested by e2e test and blink layout tests.
5250
// It can't have any other characters like '\n' or space, otherwise it will break tests.
53-
Lit.render(html`<button
51+
render(html`<button
5452
class="expand-button"
5553
tabindex="-1"
5654
aria-label=${i18nString(UIStrings.expand)}

0 commit comments

Comments
 (0)