Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 1eb8eaa

Browse files
committed
use registry symbol, remove normalization shortpath registry check
1 parent 3dfe9a6 commit 1eb8eaa

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

core/loader-polyfill.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ Loader.prototype.resolve = function (key, parent) {
120120
* as part of simplifying loader API implementation
121121
*/
122122
var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
123+
var REGISTRY = createSymbol('registry');
123124
function Registry() {
124-
this._registry = {};
125+
this[REGISTRY] = {};
126+
this._registry = REGISTRY;
125127
}
126128
// 4.4.1
127129
if (iteratorSupport) {
@@ -132,7 +134,7 @@ if (iteratorSupport) {
132134

133135
// 4.4.3
134136
Registry.prototype.entries = function () {
135-
var registry = this._registry;
137+
var registry = this[REGISTRY];
136138
return arrayValues(Object.keys(registry).map(function (key) {
137139
return [key, registry[key]];
138140
}));
@@ -141,34 +143,34 @@ if (iteratorSupport) {
141143

142144
// 4.4.4
143145
Registry.prototype.keys = function () {
144-
return arrayValues(Object.keys(this._registry));
146+
return arrayValues(Object.keys(this[REGISTRY]));
145147
};
146148
// 4.4.5
147149
Registry.prototype.values = function () {
148-
var registry = this._registry;
150+
var registry = this[REGISTRY];
149151
return arrayValues(Object.keys(registry).map(function (key) {
150152
return registry[key];
151153
}));
152154
};
153155
// 4.4.6
154156
Registry.prototype.get = function (key) {
155-
return this._registry[key];
157+
return this[REGISTRY][key];
156158
};
157159
// 4.4.7
158160
Registry.prototype.set = function (key, namespace) {
159161
if (!(namespace instanceof Module))
160162
throw new Error('Registry must be set with an instance of Module Namespace');
161-
this._registry[key] = namespace;
163+
this[REGISTRY][key] = namespace;
162164
return this;
163165
};
164166
// 4.4.8
165167
Registry.prototype.has = function (key) {
166-
return !!this._registry[key];
168+
return !!this[REGISTRY][key];
167169
};
168170
// 4.4.9
169171
Registry.prototype.delete = function (key) {
170-
if (this._registry[key]) {
171-
delete this._registry[key];
172+
if (this[REGISTRY][key]) {
173+
delete this[REGISTRY][key];
172174
return true;
173175
}
174176
return false;

core/register-loader.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ var INSTANTIATE = RegisterLoader.instantiate = createSymbol('instantiate');
4141

4242
// default normalize is the WhatWG style normalizer
4343
RegisterLoader.prototype[RESOLVE] = function (key, parentKey) {
44-
// normalization shortpath for already in registry
45-
if (this[REGISTER_REGISTRY][key] || this.registry._registry[key])
46-
return key;
4744
return resolveIfNotPlain(key, parentKey || baseURI);
4845
};
4946

@@ -122,7 +119,7 @@ function createLoadRecord (key, registration) {
122119

123120
RegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
124121
var loader = this;
125-
var registry = loader.registry._registry;
122+
var registry = loader.registry[loader.registry._registry];
126123
var registerRegistry = loader[REGISTER_REGISTRY];
127124

128125
return resolveInstantiate(loader, key, parentKey, registry, registerRegistry)

0 commit comments

Comments
 (0)