add global symbol registry to polyfill

This commit is contained in:
Sebastian McKenzie
2014-12-10 21:12:01 +11:00
parent 072fff0f4c
commit c4a0f62eef

View File

@@ -1,7 +1,7 @@
/* jshint newcap: false */
var ensureSymbol = function (key) {
Symbol[key] = Symbol[key] || Symbol();
Symbol[key] = Symbol[key] || Symbol(key);
};
var ensureProto = function (Constructor, key, val) {
@@ -13,11 +13,25 @@ var ensureProto = function (Constructor, key, val) {
if (typeof Symbol === "undefined") {
require("es6-symbol/implement");
var globSymbols = {};
Symbol.for = function (key) {
return globSymbols[key] = globSymbols[key] || Symbol(key);
};
Symbol.keyFor = function (sym) {
return sym.__description__;
};
}
require("es6-shim");
require("./transformation/transformers/es6-generators/runtime");
ensureSymbol("species");
String.prototype.includes = String.prototype.includes || String.prototype.contains;
// Abstract references
ensureSymbol("referenceGet");