Skip to content

Commit

Permalink
fix(): watch pageTitle for changes (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and jthoms1 committed Oct 12, 2018
1 parent c4bd0d0 commit 40e5290
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/router/src/components/route-title/route-title.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop, Element, ComponentInterface } from '@stencil/core';
import { Component, Prop, Element, Watch, ComponentInterface } from '@stencil/core';
import ActiveRouter from '../../global/active-router';

/**
Expand All @@ -14,9 +14,14 @@ export class RouteTitle implements ComponentInterface {
@Element() el!: HTMLStencilElement;
@Prop() titleSuffix: string = '';
@Prop() pageTitle: string = '';

@Watch('pageTitle')
updateDocumentTitle() {
document.title = `${this.pageTitle}${this.titleSuffix || ''}`;
}

componentWillLoad() {
document.title = `${this.pageTitle}${this.titleSuffix || ''}`;
this.updateDocumentTitle();
}
}

Expand Down

0 comments on commit 40e5290

Please sign in to comment.