Skip to content

Commit 86ad2a6

Browse files
committed
Redefine objects as a plain hash object
This change prevents object from inheriting the prototype chain and protect the code from unintended behaviors.
1 parent c99ef54 commit 86ad2a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function find_shims_in_package(pkgJson, cur_path, shims, browser) {
7777
function load_shims(paths, browser, cb) {
7878
// identify if our file should be replaced per the browser field
7979
// original filename|id -> replacement
80-
var shims = {};
80+
var shims = Object.create(null);
8181

8282
(function next() {
8383
var cur_path = paths.shift();
@@ -113,7 +113,7 @@ function load_shims(paths, browser, cb) {
113113
function load_shims_sync(paths, browser) {
114114
// identify if our file should be replaced per the browser field
115115
// original filename|id -> replacement
116-
var shims = {};
116+
var shims = Object.create(null);
117117
var cur_path;
118118

119119
while (cur_path = paths.shift()) {
@@ -239,7 +239,7 @@ function resolve(id, opts, cb) {
239239
id = shims[id];
240240
}
241241

242-
var modules = opts.modules || {};
242+
var modules = opts.modules || Object.create(null);
243243
var shim_path = modules[id];
244244
if (shim_path) {
245245
return cb(null, shim_path);
@@ -295,7 +295,7 @@ resolve.sync = function (id, opts) {
295295
id = shims[id];
296296
}
297297

298-
var modules = opts.modules || {};
298+
var modules = opts.modules || Object.create(null);
299299
var shim_path = modules[id];
300300
if (shim_path) {
301301
return shim_path;

0 commit comments

Comments
 (0)