Skip to content

Support prototype-less objects #1366

Open
@RReverser

Description

@RReverser

This would be a breaking change, but, I think, Object.keys, Object.entries, Object.setPrototypeOf etc. need to be changed to somehow support prototype-less objects.

In JavaScript it's common to have object values without prototype used as dictionaries created by either Object.create(null) or a corresponding literal form { __proto__: null, ... }.

These don't have Object in their prototype chain, so you can't call methods from Object.prototype on them (e.g. .to_string() won't work), and dyn_ref fails as expected.

However, you should still be able to call Object.keys, Object.values, Object.seal and other static methods, because they support such objects as well as any others.

So we need to somehow separate these two types to allow arbitrary objects in static methods, and only prototyped objects in methods that accept &self / &this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeTracking breaking changes for the next major version bump (if ever)js-sysIssues related to the `js-sys` crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions