hide subtitles if they're not set
This commit is contained in:
parent
46b1732c24
commit
695f6a3391
1 changed files with 9 additions and 6 deletions
|
@ -91,22 +91,25 @@ export class LinkEmbed extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _subtitle = ownerDocument.createElement('p')
|
const _subtitle = ownerDocument.createElement('p')
|
||||||
|
if (!this.getAttribute('subtitle')) {
|
||||||
|
_subtitle.style.display = 'hidden'
|
||||||
|
}
|
||||||
this._observers.subtitle = {
|
this._observers.subtitle = {
|
||||||
element: _subtitle,
|
element: _subtitle,
|
||||||
observer: (oldVal, newVal) => {
|
observer: (oldVal, newVal) => {
|
||||||
const { element } = this._observers.subtitle
|
const { element } = this._observers.subtitle
|
||||||
if (!!newVal) {
|
if (!!newVal) {
|
||||||
element!.innerHTML = newVal
|
element!.innerHTML = newVal
|
||||||
} else {
|
if (_subtitle.parentElement !== _textWrapper) {
|
||||||
element!.style.display = 'hidden'
|
_textWrapper.append(_subtitle)
|
||||||
|
}
|
||||||
|
} else if (_subtitle.parentElement === _textWrapper) {
|
||||||
|
_textWrapper.removeChild(_subtitle)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_textWrapper.append(
|
_textWrapper.append(_title)
|
||||||
_title,
|
|
||||||
_subtitle,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attributeChangedCallback(name: LinkEmbedAttributes, oldVal: any, newVal: any) {
|
attributeChangedCallback(name: LinkEmbedAttributes, oldVal: any, newVal: any) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue