-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
kind:featureA request, idea or new functionalityA request, idea or new functionalitytopic:interfaceRelated to safe abstractions over the primitivesRelated to safe abstractions over the primitives
Description
We are working on improving the console namespace in the LLRT project, a runtime powered by rquickjs.
awslabs/llrt#1258
For historical reasons, the console namespace must be an object without a prototype.
For historical web-compatibility reasons, the namespace object for console must have as its [[Prototype]] an empty object, created as if by ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%.
Object::new() does not meet our requirements because it creates a prototype by default.
let console = Object::new(ctx.clone())?;% cat ./reproduction.cjs
let prop = Object.getPrototypeOf(console);
console.log(Object.getOwnPropertyNames(prop));
% llrt ./reproduction.cjs
[ 'constructor', 'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__' ]
% node ./reproduction.cjs
[]
We found the implementation below to meet our requirements, but it would be nice to have a higher level API available.
let console = ctx.eval::<Object, &str>("Object.create({})")?;% llrt ./reproduction.cjs
[]
Metadata
Metadata
Assignees
Labels
kind:featureA request, idea or new functionalityA request, idea or new functionalitytopic:interfaceRelated to safe abstractions over the primitivesRelated to safe abstractions over the primitives