Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa6bb2a
commit 5bce48c
Showing
1 changed file
with
70 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,86 @@ | ||
/* eslint-disable */ | ||
|
||
// Array.findIndex Polyfill | ||
Array.prototype.findIndex = | ||
Array.prototype.findIndex || | ||
function(callback) { | ||
if (this === null) { | ||
throw new TypeError('Array.prototype.findIndex called on null or undefined'); | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('callback must be a function'); | ||
} | ||
var list = Object(this); | ||
// Makes sures is always has an positive integer as length. | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
for (var i = 0; i < length; i++) { | ||
if (callback.call(thisArg, list[i], i, list)) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
|
||
// Array.find Polyfill for IE<12. | ||
// Requested here: https://github.com/codeofsumit/leaflet.pm/issues/173 | ||
Array.prototype.find = Array.prototype.find || function(callback) { | ||
if (this === null) { | ||
throw new TypeError('Array.prototype.find called on null or undefined'); | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('callback must be a function'); | ||
} | ||
var list = Object(this); | ||
// Makes sures is always has an positive integer as length. | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
for (var i = 0; i < length; i++) { | ||
var element = list[i]; | ||
if ( callback.call(thisArg, element, i, list) ) { | ||
return element; | ||
} | ||
} | ||
}; | ||
Array.prototype.find = | ||
Array.prototype.find || | ||
function(callback) { | ||
if (this === null) { | ||
throw new TypeError('Array.prototype.find called on null or undefined'); | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('callback must be a function'); | ||
} | ||
var list = Object(this); | ||
// Makes sures is always has an positive integer as length. | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
for (var i = 0; i < length; i++) { | ||
var element = list[i]; | ||
if (callback.call(thisArg, element, i, list)) { | ||
return element; | ||
} | ||
} | ||
}; | ||
|
||
// Polyfill for Object.assign() | ||
// https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill | ||
if (typeof Object.assign != 'function') { | ||
Object.assign = function(target) { | ||
'use strict'; | ||
if (target == null) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
Object.assign = function(target) { | ||
'use strict'; | ||
if (target == null) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
|
||
target = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var source = arguments[index]; | ||
if (source != null) { | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
target = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var source = arguments[index]; | ||
if (source != null) { | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return target; | ||
}; | ||
} | ||
|
||
// Polyfill for Element.remove() | ||
// https://developer.mozilla.org/de/docs/Web/API/ChildNode/remove#Polyfill | ||
(function (arr) { | ||
arr.forEach(function (item) { | ||
if (item.hasOwnProperty('remove')) { | ||
return; | ||
} | ||
Object.defineProperty(item, 'remove', { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: function remove() { | ||
this.parentNode.removeChild(this); | ||
} | ||
(function(arr) { | ||
arr.forEach(function(item) { | ||
if (item.hasOwnProperty('remove')) { | ||
return; | ||
} | ||
Object.defineProperty(item, 'remove', { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: function remove() { | ||
this.parentNode.removeChild(this); | ||
} | ||
}); | ||
}); | ||
}); | ||
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); |