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
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js | |
index 33d8907e4f..6df7c32efd 100644 | |
--- a/lib/internal/modules/cjs/loader.js | |
+++ b/lib/internal/modules/cjs/loader.js | |
@@ -46,6 +46,9 @@ const preserveSymlinks = !!process.binding('config').preserveSymlinks; | |
const preserveSymlinksMain = !!process.binding('config').preserveSymlinksMain; | |
const experimentalModules = !!process.binding('config').experimentalModules; | |
+const { defineProperties, hasOwnProperty } = Object; | |
+const { apply } = Reflect; |
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
/** | |
* A symbol that should only be added to objects whose | |
* properties come from an external string, or which include | |
* uncherry-picked properties from such an object. | |
*/ | |
const PARSER_OUTPUT_SYMBOL = Symbol('parserOutput'); | |
function markingReviver(_, value) { | |
"use strict"; | |
if (value && typeof value === 'object') { | |
// HACK: This might fail if optReviver freezes values. |
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
class TrustedScript { // Just a stub of github.com/wicg/trusted-types | |
constructor(x) { | |
this.content = String(x); | |
} | |
toString() { | |
return this.content; | |
} | |
static createUnsafely(x) { |
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
<script>/**/alert('svg');//*/alert('html'); | |
//<![CDATA[</script><!--]]>--></script> | |
<svg> | |
<script>/**/alert('svg');//*/alert('html'); | |
//<![CDATA[</script><!--]]>--></script> | |
</svg> |
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
// On the server | |
response.write(x); | |
// On the client | |
document.body.innerHTML = x; |
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
// Run in the context of a HostEnsureCanCompileStrings callout that | |
// throws an EvalError (from the callee realm) for string values, and | |
// arrays. | |
const PASS = {}, FAIL = {}; | |
function tryCompileAsFunctionBody(description, source, expectedStatus) { | |
let status = FAIL; | |
try { | |
new Function(source); |
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
import java.lang.reflect.*; | |
import java.util.*; | |
public class Foo { | |
public static void main(String[] argv) throws Exception { | |
Class<?> integerCacheClass = Arrays.stream(Integer.class.getDeclaredClasses()) | |
.filter(c -> c.getSimpleName().equals("IntegerCache")) | |
.findFirst() | |
.get(); | |
Field cacheField = Arrays.stream(integerCacheClass.getDeclaredFields()) |
In JavaScript a nested type can read and assign variables from outer scopes.
function counter(start = 0) {
let n = start;
class Counter {
peek() { return n; }
increment() { ++n; }
}
return new Counter();
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
function cmpNums(a, b) { | |
if (Object.is(a, b)) { return 0; } | |
let delta = a - b; | |
if (delta) { | |
return Math.sign(delta); | |
} else if (delta === 0) { | |
// The only values that do not match Object.is above | |
// and which do not lead to a NaN delta are -0, +0 | |
// and vice versa. | |
return Object.is(a, -0) ? -1 : 1; |