Skip to content

CallableInstance throws error in older ECMA 5 targets #245

@justinbhopper

Description

@justinbhopper

Initial checklist

Affected packages and versions

11.0.4

Link to runnable example

No response

Steps to reproduce

The CallableInstance class is using Object.defineProperty without checking descriptor.configurable. When we used unified in a android mobile environment, we saw some differences in how the Processor class was being constructed that caused an error.

The difference we saw was if the javascript is transformed to target ES5 (ECMAScript 5.0), the Processor's copy method had a different number of property names defined than in ES6. Some of these properties are configurable: false, so calling Object.defineProperty on them throws a "Cannot redefine property: arguments" error.

In ES5:
image

In ES6 (Chrome):
image

Notice in ES6, the number of property names is simply ['length', 'name'], but in ES5 it includes additional property names that are not configurable. I believe simply checking configurable would solve this issue.

Expected behavior

Should be able to call unified() without error.

Actual behavior

Calling unified() throws an error "Cannot redefine property: arguments" during the super('copy') within the Processor's constructor.

Affected runtime and version

[email protected]

Affected package manager and version

[email protected]

Affected OS and version

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions