-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ export const { | |
JSON, | ||
Map, | ||
Math, | ||
ModuleSource, | ||
Number, | ||
Object, | ||
Promise, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
ModuleSource, | ||
functionPrototype, | ||
getPrototypeOf, | ||
objectPrototype, | ||
setPrototypeOf, | ||
} from './commons.js'; | ||
|
||
export const tameModuleSource = () => { | ||
if (ModuleSource !== undefined) { | ||
// We introduce ModuleSource.[[Proto]] === AbstractModuleSource | ||
// and ModuleSource.prototype.[[Proto]] === AbstractModuleSource.prototype | ||
// if that layer is absent because the permitting system can more | ||
// gracefully tolerate the absence of an expected prototype than the | ||
// presence of an unexpected prototype,. | ||
function AbstractModuleSource() { | ||
// no-op safe to super() | ||
} | ||
|
||
const ModuleSourceProto = getPrototypeOf(ModuleSource); | ||
if (ModuleSourceProto === functionPrototype) { | ||
setPrototypeOf(ModuleSource, AbstractModuleSource); | ||
} | ||
|
||
const ModuleSourcePrototype = ModuleSource.prototype; | ||
if (ModuleSourcePrototype !== undefined) { | ||
// ModuleSource.prototype.__proto__ should be the | ||
// AbstractModuleSource.prototype. | ||
const ModuleSourcePrototypeProto = getPrototypeOf(ModuleSourcePrototype); | ||
if (ModuleSourcePrototypeProto === objectPrototype) { | ||
setPrototypeOf(ModuleSource.prototype, AbstractModuleSource.prototype); | ||
} | ||
} | ||
} | ||
}; |