Skip to content

Commit

Permalink
feat: convert ld-input-message and ld-heading to shadow dom
Browse files Browse the repository at this point in the history
  • Loading branch information
renet committed Sep 22, 2021
1 parent cb740b8 commit 53e22aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/liquid/components/ld-heading/ld-heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { applyPropAliases } from '../../utils/applyPropAliases'
@Component({
tag: 'ld-heading',
styleUrl: 'ld-heading.css',
shadow: false,
shadow: true,
})
export class LdHeading {
@Element() el: HTMLHeadingElement
@Element() el: HTMLElement

private headingRef: HTMLHeadingElement

/** The heading level. */
@Prop() level!: 1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'
Expand Down Expand Up @@ -104,10 +106,9 @@ export class LdHeading {
this.visualLevel?.indexOf('b') === 0 ||
this.visualLevel?.indexOf('xb') === 0
if (isBHeading) {
const heading = this.el.querySelector('.ld-heading')
heading.setAttribute(
this.headingRef.setAttribute(
'aria-label',
this.ariaLabel || heading.innerHTML.trim()
this.ariaLabel || this.el.innerHTML.trim()
)
}
}
Expand All @@ -130,6 +131,7 @@ export class LdHeading {
return (
<HTag
class={cl}
ref={(ref: HTMLHeadingElement) => (this.headingRef = ref)}
{...cloneAttributes<HeadingHTMLAttributes<HTMLHeadingElement>>(this.el)}
>
<slot></slot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, h, Prop, getAssetPath } from '@stencil/core'
assetsDirs: ['assets'],
tag: 'ld-input-message',
styleUrl: 'ld-input-message.css',
shadow: false,
shadow: true,
})
export class LdInputMessage {
/** Input message mode. */
Expand Down

0 comments on commit 53e22aa

Please sign in to comment.