Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

@jkillian
Copy link

Requirements for Contributing a Bug Fix

Identify the Bug

This fixes the same issue described in #111 and in jestjs/jest#3552, that oniguruma will not work in jest when multiple tests use it.

Description of the Change

By marking length as configurable, we prevent an error from being thrown if the code is run a second time (as it will be in a jest context).

Possible Drawbacks

As far as I know, this should be harmless enough.

Verification Process

Tried out the change locally.

Release Notes

  • Fixed an issue where a reimport of the library would fail in Node.js

Copy link

@icecream17 icecream17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property descriptor is equivalent to the one you get when writing:

class OnigString {
  get length() { return this.content.length }
}

Object.getOwnPropertyDescriptor(OnigString.prototype, 'length')

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants