import { html, nothing, TemplateResult, css, render, LitElement } from '@lion/core';
const isPromise = action => typeof action === 'object' && Promise.resolve(action) === action;
/**
* Custom element for rendering SVG icons
* @polymerElement
*/
export class LionIcon extends LitElement {
static get properties() {
return {
// svg is a property to ensure the setter is called if the property is set before upgrading
svg: {
type: Object,
},
role: {
type: String,
attribute: 'role',
reflect: true,
},
ariaLabel: {
type: String,
attribute: 'aria-label',
reflect: true,
},
};
}
static get styles() {
return [
css`
:host {
box-sizing: border-box;
display: inline-block;
width: 1em;
height: 1em;
}
:host:first-child {
margin-left: 0;
}
:host:last-child {
margin-right: 0;
}
::slotted(svg) {
display: block;
width: 100%;
height: 100%;
}
`,
];
}
constructor() {
super();
this.role = 'img';
}
update(changedProperties) {
super.update(changedProperties);
if (changedProperties.has('ariaLabel')) {
this._onLabelChanged(changedProperties);
}
}
render() {
return html`
`;
}
connectedCallback() {
// ensures that aria-hidden is set if there is no aria-label attribute
this._onLabelChanged();
super.connectedCallback();
}
/**
* On IE11, svgs without focusable false appear in the tab order
* so make sure to have