Skip to content

Commit 1a10838

Browse files
committed
use hasOwnProperty in for in loops
webpack#450
1 parent 2eed596 commit 1a10838

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

‎lib/HotModuleReplacementPlugin.js‎

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ var hotInitCode = Template.getFunctionContent(function() {
367367
return;
368368
hotRequestedFilesMap[chunkId] = false;
369369
for(var moduleId in moreModules) {
370-
hotUpdate[moduleId] = moreModules[moduleId];
370+
if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
371+
hotUpdate[moduleId] = moreModules[moduleId];
372+
}
371373
}
372374
if(--hotWaitingFiles === 0 && hotChunksLoading === 0) {
373375
hotUpdateDownloaded();
@@ -394,7 +396,9 @@ var hotInitCode = Template.getFunctionContent(function() {
394396
} else {
395397
var outdatedModules = [];
396398
for(var id in hotUpdate) {
397-
outdatedModules.push(+id);
399+
if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
400+
outdatedModules.push(+id);
401+
}
398402
}
399403
callback(null, outdatedModules);
400404
}
@@ -463,25 +467,27 @@ var hotInitCode = Template.getFunctionContent(function() {
463467
var outdatedModules = [];
464468
var appliedUpdate = {};
465469
for(var id in hotUpdate) {
466-
var moduleId = +id;
467-
var result = getAffectedStuff(moduleId);
468-
if(!result) {
469-
if(options.ignoreUnaccepted)
470-
continue;
471-
hotSetStatus("abort");
472-
return callback(new Error("Aborted because " + moduleId + " is not accepted"));
473-
}
474-
if(result instanceof Error) {
475-
hotSetStatus("abort");
476-
return callback(result);
477-
}
478-
appliedUpdate[moduleId] = hotUpdate[moduleId];
479-
addAllToSet(outdatedModules, result[0]);
480-
for(var moduleId in result[1]) {
481-
if(Object.prototype.hasOwnProperty.call(result[1], moduleId)) {
482-
if(!outdatedDependencies[moduleId])
483-
outdatedDependencies[moduleId] = [];
484-
addAllToSet(outdatedDependencies[moduleId], result[1][moduleId]);
470+
if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
471+
var moduleId = +id;
472+
var result = getAffectedStuff(moduleId);
473+
if(!result) {
474+
if(options.ignoreUnaccepted)
475+
continue;
476+
hotSetStatus("abort");
477+
return callback(new Error("Aborted because " + moduleId + " is not accepted"));
478+
}
479+
if(result instanceof Error) {
480+
hotSetStatus("abort");
481+
return callback(result);
482+
}
483+
appliedUpdate[moduleId] = hotUpdate[moduleId];
484+
addAllToSet(outdatedModules, result[0]);
485+
for(var moduleId in result[1]) {
486+
if(Object.prototype.hasOwnProperty.call(result[1], moduleId)) {
487+
if(!outdatedDependencies[moduleId])
488+
outdatedDependencies[moduleId] = [];
489+
addAllToSet(outdatedDependencies[moduleId], result[1][moduleId]);
490+
}
485491
}
486492
}
487493
}

0 commit comments

Comments
 (0)