UNPKG

@stencil/router

Version:
35 lines (32 loc) 889 B
import { r as registerInstance, g as getElement } from './stencilrouter-1307249c.js'; import { A as ActiveRouter } from './chunk-cfc6485e.js'; /** * Updates the document title when found. * * @name RouteTitle * @description */ class RouteTitle { constructor(hostRef) { registerInstance(this, hostRef); this.titleSuffix = ''; this.pageTitle = ''; } updateDocumentTitle() { const el = this.el; if (el.ownerDocument) { el.ownerDocument.title = `${this.pageTitle}${this.titleSuffix || ''}`; } } componentWillLoad() { this.updateDocumentTitle(); } get el() { return getElement(this); } static get watchers() { return { "pageTitle": ["updateDocumentTitle"] }; } } ActiveRouter.injectProps(RouteTitle, [ 'titleSuffix', ]); export { RouteTitle as stencil_route_title };