refactor: bundle template.js respectively

This commit is contained in:
harttle
2018-08-27 21:37:39 +08:00
parent 31c39561c9
commit d6876bd9ec
19 changed files with 4386 additions and 2152 deletions
-17
View File
@@ -1,17 +0,0 @@
export function get (url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest()
xhr.onload = () => {
if (xhr.status >= 200 && xhr.status < 300) {
resolve(xhr.responseText)
} else {
reject(new Error(xhr.statusText))
}
}
xhr.onerror = () => {
reject(new Error('An error occurred whilst sending the response.'))
}
xhr.open('GET', url)
xhr.send()
})
}
-41
View File
@@ -1,41 +0,0 @@
import {last, isArray} from './underscore'
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/
const urlRe = /^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/
// https://github.com/jinder/path/blob/master/path.js#L567
export function extname (path) {
return splitPathRe.exec(path).slice(1)[3]
}
// https://www.npmjs.com/package/is-url
export function valid (path) {
return urlRe.test(path)
}
export function resolve (root, path) {
if (isArray(root)) {
root = root[0]
}
if (root && last(root) !== '/') {
root += '/'
}
return resolveUrl(root, path)
}
function resolveUrl (root, path) {
const base = document.createElement('base')
base.href = arguments[0]
const head = document.getElementsByTagName('head')[0]
head.insertBefore(base, head.firstChild)
const a = document.createElement('a')
a.href = path
const resolved = a.href
base.href = resolved
head.removeChild(base)
return resolved
}