Application.ts passes strict mode compile
This commit is contained in:
parent
8d7661cf9e
commit
e4a5230f8c
@ -13,7 +13,7 @@ export class Application {
|
|||||||
loading: HTMLElement
|
loading: HTMLElement
|
||||||
currentPath: string
|
currentPath: string
|
||||||
originalPath: string
|
originalPath: string
|
||||||
lastRequest: XMLHttpRequest
|
lastRequest: XMLHttpRequest | null
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.currentPath = window.location.pathname
|
this.currentPath = window.location.pathname
|
||||||
@ -30,7 +30,7 @@ export class Application {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
find(id: string): HTMLElement {
|
find(id: string): HTMLElement | null {
|
||||||
return document.getElementById(id)
|
return document.getElementById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +76,11 @@ export class Application {
|
|||||||
this.currentPath = url
|
this.currentPath = url
|
||||||
|
|
||||||
// Add to browser history
|
// Add to browser history
|
||||||
if(options.addToHistory)
|
if(options.addToHistory) {
|
||||||
history.pushState(url, null, url)
|
history.pushState(url, "", url)
|
||||||
|
}
|
||||||
|
|
||||||
let onTransitionEnd = e => {
|
let onTransitionEnd = (e: Event) => {
|
||||||
// Ignore transitions of child elements.
|
// Ignore transitions of child elements.
|
||||||
// We only care about the transition event on the content element.
|
// We only care about the transition event on the content element.
|
||||||
if(e.target !== this.content) {
|
if(e.target !== this.content) {
|
||||||
@ -118,8 +119,9 @@ export class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
markActiveLinks(element?: HTMLElement) {
|
markActiveLinks(element?: HTMLElement) {
|
||||||
if(element === undefined)
|
if(!element) {
|
||||||
element = document.body
|
element = document.body
|
||||||
|
}
|
||||||
|
|
||||||
let links = element.getElementsByTagName("a")
|
let links = element.getElementsByTagName("a")
|
||||||
|
|
||||||
@ -135,8 +137,9 @@ export class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ajaxify(element?: HTMLElement) {
|
ajaxify(element?: HTMLElement) {
|
||||||
if(!element)
|
if(!element) {
|
||||||
element = document.body
|
element = document.body
|
||||||
|
}
|
||||||
|
|
||||||
let links = element.querySelectorAll("." + this.ajaxClass)
|
let links = element.querySelectorAll("." + this.ajaxClass)
|
||||||
|
|
||||||
@ -155,10 +158,6 @@ export class Application {
|
|||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
// if(this.dataset.bubble !== "true") {
|
|
||||||
// e.stopPropagation()
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(!url || url === self.currentPath)
|
if(!url || url === self.currentPath)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -169,7 +168,7 @@ export class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
scrollToTop() {
|
||||||
let parent = this.content
|
let parent : HTMLElement | null = this.content
|
||||||
|
|
||||||
while(parent = parent.parentElement) {
|
while(parent = parent.parentElement) {
|
||||||
parent.scrollTop = 0
|
parent.scrollTop = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user