Skip to content

Commit

Permalink
Fix null computedHref when href is loaded after creation
Browse files Browse the repository at this point in the history
```
vue.js:597 [Vue warn]: Error in render: "TypeError: Cannot read property 'startsWith' of null"

found in

---> <AppLink>
       <Config>
         <Root>
```
  • Loading branch information
sharkykh committed Jul 4, 2018
1 parent 2de7d08 commit e13d1af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions themes-default/slim/views/vue-components/app-link.mako
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,28 @@ Vue.component('app-link', {
return href;
},
isIRC() {
if (!this.computedHref) return;
return this.computedHref.startsWith('irc://');
},
isAbsolute() {
const href = this.computedHref;
if (!href) return;
return /^[a-z][a-z0-9+.-]*:/.test(href);
},
isExternal() {
const base = this.computedBase;
const href = this.computedHref;
if (!href) return;
return !href.startsWith(base) && !href.startsWith('webcal://');
},
isHashPath() {
if (!this.computedHref) return;
return this.computedHref.startsWith('#');
},
anonymisedHref() {
const { anonRedirect } = this.config;
const href = this.computedHref;
if (!href) return;
return anonRedirect ? anonRedirect + href : href;
},
linkProperties() {
Expand Down
5 changes: 5 additions & 0 deletions themes/dark/templates/vue-components/app-link.mako
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,28 @@ Vue.component('app-link', {
return href;
},
isIRC() {
if (!this.computedHref) return;
return this.computedHref.startsWith('irc://');
},
isAbsolute() {
const href = this.computedHref;
if (!href) return;
return /^[a-z][a-z0-9+.-]*:/.test(href);
},
isExternal() {
const base = this.computedBase;
const href = this.computedHref;
if (!href) return;
return !href.startsWith(base) && !href.startsWith('webcal://');
},
isHashPath() {
if (!this.computedHref) return;
return this.computedHref.startsWith('#');
},
anonymisedHref() {
const { anonRedirect } = this.config;
const href = this.computedHref;
if (!href) return;
return anonRedirect ? anonRedirect + href : href;
},
linkProperties() {
Expand Down
5 changes: 5 additions & 0 deletions themes/light/templates/vue-components/app-link.mako
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,28 @@ Vue.component('app-link', {
return href;
},
isIRC() {
if (!this.computedHref) return;
return this.computedHref.startsWith('irc://');
},
isAbsolute() {
const href = this.computedHref;
if (!href) return;
return /^[a-z][a-z0-9+.-]*:/.test(href);
},
isExternal() {
const base = this.computedBase;
const href = this.computedHref;
if (!href) return;
return !href.startsWith(base) && !href.startsWith('webcal://');
},
isHashPath() {
if (!this.computedHref) return;
return this.computedHref.startsWith('#');
},
anonymisedHref() {
const { anonRedirect } = this.config;
const href = this.computedHref;
if (!href) return;
return anonRedirect ? anonRedirect + href : href;
},
linkProperties() {
Expand Down

0 comments on commit e13d1af

Please sign in to comment.