Uglify doesn't support ES6 yet.

This commit is contained in:
Guo Xiang Tan 2017-11-28 16:07:27 +08:00
parent 7b8699f3be
commit 110dfbf42f
1 changed files with 10 additions and 10 deletions

View File

@ -11,7 +11,7 @@ const CURRENT_CACHES = {
const OFFLINE_URL = 'offline.html';
function createCacheBustedRequest(url) {
let request = new Request(url, {cache: 'reload'});
var request = new Request(url, {cache: 'reload'});
// See https://fetch.spec.whatwg.org/#concept-request-mode
// This is not yet supported in Chrome as of M48, so we need to explicitly check to see
// if the cache: 'reload' option had any effect.
@ -20,12 +20,12 @@ function createCacheBustedRequest(url) {
}
// If {cache: 'reload'} didn't have any effect, append a cache-busting URL parameter instead.
let bustedUrl = new URL(url, self.location.href);
bustedUrl.search += `${(bustedUrl.search ? '&' : '')}cachebust=${Date.now()}`;
var bustedUrl = new URL(url, self.location.href);
bustedUrl.search += (bustedUrl.search ? '&' : '') + 'cachebust=' + Date.now();
return new Request(bustedUrl);
}
self.addEventListener('install', event => {
self.addEventListener('install', function(event) {
event.waitUntil(
// We can't use cache.add() here, since we want OFFLINE_URL to be the cache key, but
// the actual URL we end up requesting might include a cache-busting parameter.
@ -37,18 +37,18 @@ self.addEventListener('install', event => {
);
});
self.addEventListener('activate', event => {
self.addEventListener('activate', function(event) {
// Delete all caches that aren't named in CURRENT_CACHES.
// While there is only one cache in this example, the same logic will handle the case where
// there are multiple versioned caches.
let expectedCacheNames = Object.keys(CURRENT_CACHES).map(function(key) {
var expectedCacheNames = Object.keys(CURRENT_CACHES).map(function(key) {
return CURRENT_CACHES[key];
});
event.waitUntil(
caches.keys().then(cacheNames => {
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(cacheName => {
cacheNames.map(function(cacheName) {
if (expectedCacheNames.indexOf(cacheName) === -1) {
// If this cache name isn't present in the array of "expected" cache names,
// then delete it.
@ -60,7 +60,7 @@ self.addEventListener('activate', event => {
);
});
self.addEventListener('fetch', event => {
self.addEventListener('fetch', function(event) {
// We only want to call event.respondWith() if this is a navigation request
// for an HTML page.
// request.mode of 'navigate' is unfortunately not supported in Chrome
@ -70,7 +70,7 @@ self.addEventListener('fetch', event => {
(event.request.method === 'GET' &&
event.request.headers.get('accept').includes('text/html'))) {
event.respondWith(
fetch(event.request).catch(error => {
fetch(event.request).catch(function(error) {
// The catch is only triggered if fetch() throws an exception, which will most likely
// happen due to the server being unreachable.
// If fetch() returns a valid HTTP response with an response code in the 4xx or 5xx