Skip to content

Commit

Permalink
fix(gv-icon): use svg lit directive
Browse files Browse the repository at this point in the history
  • Loading branch information
gcusnieux authored and gaetanmaisse committed Apr 21, 2022
1 parent a2e95dd commit 46a4706
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/atoms/gv-icon/gv-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { css, LitElement, html, noChange } from 'lit';
import { Directive, directive } from 'lit/directive.js';
import { css, LitElement, html, svg } from 'lit';

import { classMap } from 'lit/directives/class-map.js';

class Namespaced extends Directive {
update(part, [namespace, value]) {
part.element.setAttributeNS(namespace, part.name, value);
return noChange;
}
}

const namespaced = directive(Namespaced);

/**
* An icon
*
Expand Down Expand Up @@ -93,10 +83,8 @@ export class GvIcon extends LitElement {
}

render() {
const xlinkNamespace = 'http://www.w3.org/1999/xlink';
return html`<svg class="${classMap({ 'no-color': !this.canCustomize() })}">
<use xlink:href="${namespaced(xlinkNamespace, GvIcon.getHref(this.shape))}" />
</svg>`;
const icon = svg`<use href="${GvIcon.getHref(this.shape)}" />`;
return html`<svg xmlns="http://www.w3.org/2000/svg" class="${classMap({ 'no-color': !this.canCustomize() })}">${icon}</svg>`;
}
}

Expand Down

0 comments on commit 46a4706

Please sign in to comment.