@stencil/core
Version:
A Compiler for Web Components and Progressive Web Apps
1 lines • 1.31 kB
JavaScript
import{r as t,h as s,g as i}from"./p-c001178f.js";import{m as a,q as h}from"./p-8f0955b7.js";import{A as r}from"./p-5ada7d7c.js";const c=(t,s)=>"/"==t.charAt(0)&&"/"==s.charAt(s.length-1)?s.slice(0,s.length-1)+t:s+t;class e{constructor(s){t(this,s),this.unsubscribe=()=>{},this.activeClass="link-active",this.exact=!1,this.strict=!0,this.custom="a",this.match=null}componentWillLoad(){this.computeMatch()}computeMatch(){this.location&&(this.match=a(this.location.pathname,{path:this.urlMatch||this.url,exact:this.exact,strict:this.strict}))}handleClick(t){if(!h(t)&&this.history&&this.url&&this.root)return t.preventDefault(),this.history.push(c(this.url,this.root))}render(){let t={class:{[this.activeClass]:null!==this.match},onClick:this.handleClick.bind(this)};return this.anchorClass&&(t.class[this.anchorClass]=!0),"a"===this.custom&&(t=Object.assign({},t,{href:this.url,title:this.anchorTitle,role:this.anchorRole,tabindex:this.anchorTabIndex,"aria-haspopup":this.ariaHaspopup,id:this.anchorId,"aria-posinset":this.ariaPosinset,"aria-setsize":this.ariaSetsize,"aria-label":this.ariaLabel})),s(this.custom,Object.assign({},t),s("slot",null))}get el(){return i(this)}static get watchers(){return{location:["computeMatch"]}}}r.injectProps(e,["history","location","root"]);export{e as stencil_route_link};