move ES6 polyfills into lang

This commit is contained in:
Steven Orvell
2016-12-01 11:13:12 -08:00
parent ff87ab9681
commit 130ecb3bf3
4 changed files with 46 additions and 39 deletions

View File

@@ -5,7 +5,11 @@
"../MutationObserver/MutationObserver.js",
"../Template/Template.js",
"../HTMLImports/build.json",
"../CustomElements/build.json",
"Promise.js",
"../../custom-elements/custom-elements.min.js",
"../../shadydom/shadydom.min.js",
"../../shadycss/shadycss.min.js",
"lang.js",
"dom.js",
"unresolved.js"
]

View File

@@ -128,31 +128,4 @@
window.MouseEvent.prototype = origMouseEvent.prototype;
}
if (!Array.from) {
Array.from = function (object) {
return [].slice.call(object);
};
}
if (!Object.assign) {
function assign(target, source) {
var n$ = Object.getOwnPropertyNames(source);
for (var i=0, p; i < n$.length; i++) {
p = n$[i];
target[p] = source[p];
}
}
Object.assign = function(target, sources) {
var args = [].slice.call(arguments, 1);
for (var i=0, s; i < args.length; i++) {
s = args[i];
if (s) {
assign(target, s);
}
}
return target;
}
}
})(window.WebComponents);

View File

@@ -10,18 +10,47 @@
(function(scope) {
// Old versions of iOS do not have bind.
'use strict';
if (!Function.prototype.bind) {
Function.prototype.bind = function(scope) {
var self = this;
var args = Array.prototype.slice.call(arguments, 1);
return function() {
var args2 = args.slice();
args2.push.apply(args2, arguments);
return self.apply(scope, args2);
// Old versions of iOS do not have bind.
if (!Function.prototype.bind) {
Function.prototype.bind = function(scope) {
var self = this;
var args = Array.prototype.slice.call(arguments, 1);
return function() {
var args2 = args.slice();
args2.push.apply(args2, arguments);
return self.apply(scope, args2);
};
};
};
}
}
// ES6 stuff
if (!Array.from) {
Array.from = function (object) {
return [].slice.call(object);
};
}
if (!Object.assign) {
function assign(target, source) {
var n$ = Object.getOwnPropertyNames(source);
for (var i=0, p; i < n$.length; i++) {
p = n$[i];
target[p] = source[p];
}
}
Object.assign = function(target, sources) {
var args = [].slice.call(arguments, 1);
for (var i=0, s; i < args.length; i++) {
s = args[i];
if (s) {
assign(target, s);
}
}
return target;
}
}
})(window.WebComponents);

View File

@@ -61,6 +61,7 @@
'../../shadycss/shadycss.min.js',
'WebComponents/post-polyfill.js',
// these scripts are loaded here due to polyfill timing issues
'WebComponents/lang.js',
'WebComponents/dom.js',
'WebComponents/unresolved.js'
];