kd-polyfills
Version:
85 lines (72 loc) • 2.38 kB
JavaScript
try {
document.write = document.writeln = function () {
throw new Error('document.[write|writeln] is nisht-nisht');
};
} catch (e) {}
(function(window) {
var e, _base, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
(_base = Function.prototype).bind || (_base.bind = function(context) {
var args;
if (1 < arguments.length) {
args = [].slice.call(arguments, 1);
return (function(_this) {
return function() {
return _this.apply(context, arguments.length ? args.concat([].slice.call(arguments)) : args);
};
})(this);
}
return (function(_this) {
return function() {
if (arguments.length) {
return _this.apply(context, arguments);
} else {
return _this.call(context);
}
};
})(this);
});
if (!window.URL) {
window.URL = (_ref = window.webkitURL) != null ? _ref : null;
}
if (!window.BlobBuilder) {
window.BlobBuilder = (_ref1 = (_ref2 = window.WebKitBlobBuilder) != null ? _ref2 : window.MozBlobBuilder) != null ? _ref1 : null;
}
if (!window.requestFileSystem) {
window.requestFileSystem = (_ref3 = window.webkitRequestFileSystem) != null ? _ref3 : null;
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (_ref4 = (_ref5 = window.webkitRequestAnimationFrame) != null ? _ref5 : window.mozRequestAnimationFrame) != null ? _ref4 : null;
}
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
(function(arrayProto, _arg) {
var defineProperty;
defineProperty = _arg.defineProperty;
"last" in arrayProto || defineProperty(arrayProto, "last", {
get: function() {
return this[this.length - 1];
}
});
return "first" in arrayProto || defineProperty(arrayProto, "first", {
get: function() {
return this[0];
}
});
})(Array.prototype, Object);
if (!window.event) {
try {
Object.defineProperty(window, "event", {
get: function() {
return console.warn("Global \"event\" property is accessed. Did you forget a parameter in a DOM event handler?");
}
});
} catch (_error) {
e = _error;
console.log("we fail silently!", e);
}
}
})(this);