Skip to content

Commit b6f89a8

Browse files
committed
perf: allow html literals to be minified
minify-html-literals does not support tag-name interpolations yet
1 parent 62a5d64 commit b6f89a8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.changeset/calm-cheetahs-burn.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@patternfly/pfe-accordion": patch
3+
"@patternfly/pfe-primary-detail": patch
4+
---
5+
6+
allow HTML literals to be optimized by aliasing static html tag

elements/pfe-accordion/pfe-accordion-header.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { LitElement, html as _html } from 'lit';
1+
import { LitElement, html } from 'lit';
22
import { customElement, property, query } from 'lit/decorators.js';
3-
import { withStatic, unsafeStatic } from 'lit/static-html.js';
3+
import { unsafeStatic, html as staticH } from 'lit/static-html.js';
44

55
import { ComposedEvent } from '@patternfly/pfe-core';
66
import { pfelement, bound, observed, initializer } from '@patternfly/pfe-core/decorators.js';
@@ -13,8 +13,6 @@ import style from './pfe-accordion-header.scss';
1313

1414
import '@patternfly/pfe-icon';
1515

16-
const html = withStatic(_html);
17-
1816
const isPorHeader =
1917
(el: Node): el is HTMLElement =>
2018
el instanceof HTMLElement && !!el.tagName.match(/P|^H[1-6]/);
@@ -111,8 +109,8 @@ export class PfeAccordionHeader extends LitElement {
111109

112110
override render() {
113111
const tag = unsafeStatic(this.headingTag);
114-
return html`
115-
<${tag} id="heading">
112+
return staticH`
113+
<${tag} id="heading">${html`
116114
<button id="button"
117115
aria-expanded="${this.ariaExpandedState}"
118116
class="pf-c-accordion__toggle">
@@ -134,7 +132,7 @@ export class PfeAccordionHeader extends LitElement {
134132
part="icon"
135133
class="pf-c-accordion__toggle-icon"
136134
></pfe-icon>
137-
</button>
135+
</button>`}
138136
</${tag}>
139137
`;
140138
}

elements/pfe-primary-detail/pfe-primary-detail.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { TemplateResult } from 'lit';
22

33
import { LitElement, html } from 'lit';
44
import { customElement, property, query, state } from 'lit/decorators.js';
5-
import { html as statichtml, unsafeStatic } from 'lit/static-html.js';
5+
import { html as staticH, unsafeStatic } from 'lit/static-html.js';
66
import { classMap } from 'lit/directives/class-map.js';
77
import { ifDefined } from 'lit/directives/if-defined.js';
88

@@ -610,7 +610,7 @@ export class PfePrimaryDetail extends LitElement {
610610
// If wasTag isn't a headline, use strong
611611
const tag = unsafeStatic(wasTag?.match(/^H/i) ? wasTag : 'strong');
612612

613-
return statichtml`
613+
return staticH`
614614
<${tag} id="details-wrapper__heading">
615615
${this.expandedSectionTitle}
616616
</${tag}>`;

0 commit comments

Comments
 (0)