remove URLSearchParams

This commit is contained in:
Nolan Lawson 2018-03-09 00:08:23 -08:00
parent f42a07162b
commit 346cfa0e2c
8 changed files with 52 additions and 72 deletions

62
package-lock.json generated
View File

@ -8106,9 +8106,9 @@
} }
}, },
"sapper": { "sapper": {
"version": "github:nolanlawson/sapper#6f6c17aa0763bf1c9e1f268ff2e220551803992d", "version": "github:nolanlawson/sapper#ec86bbb81d6b7346d3332b3d31fd507a01010f2f",
"requires": { "requires": {
"chalk": "2.3.0", "chalk": "2.3.2",
"chokidar": "1.7.0", "chokidar": "1.7.0",
"escape-html": "1.0.3", "escape-html": "1.0.3",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
@ -8116,7 +8116,7 @@
"require-relative": "0.8.7", "require-relative": "0.8.7",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"webpack": "3.11.0", "webpack": "3.11.0",
"webpack-hot-middleware": "2.21.0" "webpack-hot-middleware": "2.21.2"
}, },
"dependencies": { "dependencies": {
"acorn-dynamic-import": { "acorn-dynamic-import": {
@ -8150,9 +8150,9 @@
"integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=" "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74="
}, },
"ansi-styles": { "ansi-styles": {
"version": "3.2.0", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"requires": { "requires": {
"color-convert": "1.9.1" "color-convert": "1.9.1"
} }
@ -8195,13 +8195,13 @@
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0="
}, },
"chalk": { "chalk": {
"version": "2.3.0", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==",
"requires": { "requires": {
"ansi-styles": "3.2.0", "ansi-styles": "3.2.1",
"escape-string-regexp": "1.0.5", "escape-string-regexp": "1.0.5",
"supports-color": "4.5.0" "supports-color": "5.3.0"
} }
}, },
"chokidar": { "chokidar": {
@ -8278,9 +8278,9 @@
} }
}, },
"has-flag": { "has-flag": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
}, },
"is-extglob": { "is-extglob": {
"version": "1.0.0", "version": "1.0.0",
@ -8316,11 +8316,11 @@
} }
}, },
"supports-color": { "supports-color": {
"version": "4.5.0", "version": "5.3.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==",
"requires": { "requires": {
"has-flag": "2.0.0" "has-flag": "3.0.0"
} }
}, },
"tapable": { "tapable": {
@ -8365,6 +8365,21 @@
"watchpack": "1.5.0", "watchpack": "1.5.0",
"webpack-sources": "1.1.0", "webpack-sources": "1.1.0",
"yargs": "8.0.2" "yargs": "8.0.2"
},
"dependencies": {
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
},
"supports-color": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=",
"requires": {
"has-flag": "2.0.0"
}
}
} }
}, },
"yargs": { "yargs": {
@ -10235,11 +10250,6 @@
} }
} }
}, },
"url-search-params": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/url-search-params/-/url-search-params-0.10.0.tgz",
"integrity": "sha512-oFPzmbPAbdthStgffGq8alULe47skPDt1X3KW6NOQnKkcLHP4IS1NfdfHG/CBP5lGsr2gDzNp87pfWLx/eIxjw=="
},
"use": { "use": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/use/-/use-2.0.2.tgz", "resolved": "https://registry.npmjs.org/use/-/use-2.0.2.tgz",
@ -10707,9 +10717,9 @@
} }
}, },
"webpack-hot-middleware": { "webpack-hot-middleware": {
"version": "2.21.0", "version": "2.21.2",
"resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.21.0.tgz", "resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.21.2.tgz",
"integrity": "sha512-P6xiOLy10QlSVSO7GanU9PLxN6zLLQ7RG16MPTvmFwf2KUG7jMp6m+fmdgsR7xoaVVLA7OlX3YO6JjoZEKjCuA==", "integrity": "sha512-N5c80o31E0COFJV8HRjiX3hJetDOwQ2Ajt5TTORKA9diOimhFtmaZKSfO3pQKMeQngb7I4TUnNDroJiUzPFhKQ==",
"requires": { "requires": {
"ansi-html": "0.0.7", "ansi-html": "0.0.7",
"html-entities": "1.2.1", "html-entities": "1.2.1",

View File

@ -54,7 +54,7 @@
"pify": "^3.0.0", "pify": "^3.0.0",
"quick-lru": "^1.1.0", "quick-lru": "^1.1.0",
"requestidlecallback": "^0.3.0", "requestidlecallback": "^0.3.0",
"sapper": "nolanlawson/sapper#fix-style-loader-built", "sapper": "nolanlawson/sapper#monkey-patches",
"serve-static": "^1.13.1", "serve-static": "^1.13.1",
"standard": "^10.0.3", "standard": "^10.0.3",
"stringz": "^0.4.0", "stringz": "^0.4.0",
@ -67,7 +67,6 @@
"testcafe": "^0.19.0-alpha1", "testcafe": "^0.19.0-alpha1",
"timeago.js": "^3.0.2", "timeago.js": "^3.0.2",
"tiny-queue": "^0.2.1", "tiny-queue": "^0.2.1",
"url-search-params": "^0.10.0",
"webpack": "^4.1.0", "webpack": "^4.1.0",
"webpack-bundle-analyzer": "^2.11.1", "webpack-bundle-analyzer": "^2.11.1",
"workerize-loader": "^1.0.1", "workerize-loader": "^1.0.1",
@ -86,7 +85,6 @@
"requestIdleCallback", "requestIdleCallback",
"location", "location",
"localStorage", "localStorage",
"URLSearchParams",
"IntersectionObserver", "IntersectionObserver",
"URL", "URL",
"Event", "Event",

View File

@ -69,9 +69,12 @@ export async function get (url, headers = {}) {
} }
export function paramsString (paramsObject) { export function paramsString (paramsObject) {
let params = new URLSearchParams() let res = ''
Object.keys(paramsObject).forEach(key => { Object.keys(paramsObject).forEach((key, i) => {
params.set(key, paramsObject[key]) if (i > 0) {
res += '&'
}
res += encodeURIComponent(key) + '=' + encodeURIComponent(paramsObject[key])
}) })
return params.toString() return res
} }

View File

@ -1,14 +1,3 @@
export const importURLSearchParams = () => import(
/* webpackChunkName: 'url-search-params' */ 'url-search-params'
).then(Params => {
window.URLSearchParams = Params
Object.defineProperty(window.URL.prototype, 'searchParams', {
get() {
return new Params(this.search)
}
})
})
export const importTimeline = () => import( export const importTimeline = () => import(
/* webpackChunkName: 'Timeline' */ '../_components/timeline/Timeline.html' /* webpackChunkName: 'Timeline' */ '../_components/timeline/Timeline.html'
).then(mod => mod.default) ).then(mod => mod.default)

View File

@ -1,5 +1,4 @@
import { import {
importURLSearchParams,
importIntersectionObserver, importIntersectionObserver,
importRequestIdleCallback, importRequestIdleCallback,
importIndexedDBGetAllShim importIndexedDBGetAllShim
@ -7,7 +6,6 @@ import {
export function loadPolyfills () { export function loadPolyfills () {
return Promise.all([ return Promise.all([
typeof URLSearchParams === 'undefined' && importURLSearchParams(),
typeof IntersectionObserver === 'undefined' && importIntersectionObserver(), typeof IntersectionObserver === 'undefined' && importIntersectionObserver(),
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(), typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim() !IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim()

View File

@ -1,25 +1,18 @@
import { thunk } from './thunk' const enabled = process.browser && performance.mark && (
process.env.NODE_ENV !== 'production' ||
// Lazily invoke because URLSearchParams isn't supported in Edge 16, location.search.includes('marks=true')
// so we need the polyfill.
const enabled = thunk(() => process.browser &&
performance.mark &&
(
process.env.NODE_ENV !== 'production' ||
new URLSearchParams(location.search).get('marks') === 'true'
)
) )
const perf = process.browser && performance const perf = process.browser && performance
export function mark (name) { export function mark (name) {
if (enabled()) { if (enabled) {
perf.mark(`start ${name}`) perf.mark(`start ${name}`)
} }
} }
export function stop (name) { export function stop (name) {
if (enabled()) { if (enabled) {
perf.mark(`end ${name}`) perf.mark(`end ${name}`)
perf.measure(name, `start ${name}`, `end ${name}`) perf.measure(name, `start ${name}`, `end ${name}`)
} }

View File

@ -1,11 +0,0 @@
export function thunk (fn) {
let value
let called
return () => {
if (!called) {
value = fn()
called = true
}
return value
}
}

View File

@ -77,9 +77,9 @@
export default { export default {
async oncreate () { async oncreate () {
let params = new URLSearchParams(location.search) let codeMatch = location.search.match(/code=([^&]+)/)
if (params.has('code')) { if (codeMatch) {
handleOauthCode(params.get('code')) handleOauthCode(codeMatch[1])
} }
}, },
components: { components: {