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

View file

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

View file

@ -69,9 +69,12 @@ export async function get (url, headers = {}) {
}
export function paramsString (paramsObject) {
let params = new URLSearchParams()
Object.keys(paramsObject).forEach(key => {
params.set(key, paramsObject[key])
let res = ''
Object.keys(paramsObject).forEach((key, i) => {
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(
/* webpackChunkName: 'Timeline' */ '../_components/timeline/Timeline.html'
).then(mod => mod.default)

View file

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

View file

@ -1,25 +1,18 @@
import { thunk } from './thunk'
// Lazily invoke because URLSearchParams isn't supported in Edge 16,
// 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 enabled = process.browser && performance.mark && (
process.env.NODE_ENV !== 'production' ||
location.search.includes('marks=true')
)
const perf = process.browser && performance
export function mark (name) {
if (enabled()) {
if (enabled) {
perf.mark(`start ${name}`)
}
}
export function stop (name) {
if (enabled()) {
if (enabled) {
perf.mark(`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 {
async oncreate () {
let params = new URLSearchParams(location.search)
if (params.has('code')) {
handleOauthCode(params.get('code'))
let codeMatch = location.search.match(/code=([^&]+)/)
if (codeMatch) {
handleOauthCode(codeMatch[1])
}
},
components: {