UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

4 lines 1.07 kB
/*! * NENT 2022 */ import{r as t,h as i,a as s}from"./index-916ca544.js";import{s as e,o as n}from"./state-adf07580.js";import"./index-4bfabbbd.js";const h=class{constructor(i){t(this,i),this.exact=!1,this.strict=!0}get parentUrl(){var t,i;return(null===(t=this.el.closest("n-view-prompt"))||void 0===t?void 0:t.path)||(null===(i=this.el.closest("n-view"))||void 0===i?void 0:i.path)}checkRoutingState(){if(!e||!e.router)return;this.route=e.router.resolvePathname(this.route,this.parentUrl||"/"),this.routeMatch&&(this.routeMatch=new RegExp(this.routeMatch,this.strict?void 0:"i"));const t=e.router.matchPath({path:null!=this.routeMatch?this.routeMatch:this.route,exact:this.exact,strict:this.strict});this.match=t?Object.assign({},t):null}componentWillLoad(){this.checkRoutingState(),this.routeSubscription=n("location",(()=>{this.checkRoutingState()}))}render(){return i("slot",this.match?{name:"active"}:{name:"inactive"})}disconnectedCallback(){var t;null===(t=this.routeSubscription)||void 0===t||t.call(this)}get el(){return s(this)}};export{h as n_view_detect}