Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
client: Remove fetch() polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
bakape committed Sep 12, 2018
1 parent ba0683a commit 091d918
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 65 deletions.
1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -49,7 +49,6 @@ watch:
client_vendor: client_deps
mkdir -p www/js/vendor
cp node_modules/dom4/build/dom4.js node_modules/core-js/client/core.min.js node_modules/core-js/client/core.min.js.map www/js/vendor
$(uglifyjs) node_modules/whatwg-fetch/fetch.js -o www/js/vendor/fetch.js
$(uglifyjs) node_modules/almond/almond.js -o www/js/vendor/almond.js

css:
Expand Down
51 changes: 23 additions & 28 deletions clientScripts/loader.js
Expand Up @@ -3,10 +3,10 @@
(function () {
// Check if the client is an automated crawler
var isBot,
botStrings = [
"bot", "googlebot", "crawler", "spider", "robot", "crawling"
];
botStrings = [
"bot", "googlebot", "crawler", "spider", "robot", "crawling"
];

for (var i = 0; i < botStrings.length; i++) {
if (navigator.userAgent.indexOf(botStrings[i]) !== -1) {
isBot = true;
Expand Down Expand Up @@ -35,7 +35,7 @@

while (ns.length) { // Collection is live and changes with DOM updates
var el = ns[0],
cont = document.createElement("div");
cont = document.createElement("div");
cont.innerHTML = el.innerHTML;
el.parentNode.replaceChild(cont, el);
}
Expand All @@ -47,29 +47,24 @@
}

var scriptCount = 0,
polyfills = [];

// Fetch API
if (!checkFunction("window.fetch")) {
polyfills.push('js/vendor/fetch');
}
polyfills = [];

var DOMUpToDate = true,
DOMMethods = [
// DOM level 4 methods
'Element.prototype.remove',
'Element.prototype.contains',
'Element.prototype.matches',
'Element.prototype.after',
'Element.prototype.before',
'Element.prototype.append',
'Element.prototype.prepend',
'Element.prototype.replaceWith',

// DOM level 3 query methods
'Element.prototype.querySelector',
'Element.prototype.querySelectorAll'
];
DOMMethods = [
// DOM level 4 methods
'Element.prototype.remove',
'Element.prototype.contains',
'Element.prototype.matches',
'Element.prototype.after',
'Element.prototype.before',
'Element.prototype.append',
'Element.prototype.prepend',
'Element.prototype.replaceWith',

// DOM level 3 query methods
'Element.prototype.querySelector',
'Element.prototype.querySelectorAll'
];

for (i = 0; i < DOMMethods.length; i++) {
if (!checkFunction(DOMMethods[i])) {
Expand Down Expand Up @@ -117,7 +112,7 @@
}

var wasm = /[\?&]wasm=true/.test(location.search),
head = document.getElementsByTagName('head')[0];
head = document.getElementsByTagName('head')[0];

if (polyfills.length) {
for (i = 0; i < polyfills.length; i++) {
Expand Down Expand Up @@ -191,7 +186,7 @@

if ('serviceWorker' in navigator && (
location.protocol === "https:" ||
location.hostname === "localhost"
location.hostname === "localhost"
)) {
navigator.serviceWorker
.register("/assets/js/scripts/worker.js", { scope: "/" })
Expand Down
68 changes: 34 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -23,7 +23,6 @@
"gulp-uglify": "latest",
"gulp-util": "latest",
"typescript": "latest",
"uglify-js": "latest",
"whatwg-fetch": "^2.0.4"
"uglify-js": "latest"
}
}

0 comments on commit 091d918

Please sign in to comment.