zloirock / core-js

Standard Library
MIT License
23.99k stars 1.62k forks source link

`writable` values of `Symbol.toStringTag` property of `DOMIterables` are overwritten to `true` #1312

Closed canalun closed 6 months ago

canalun commented 6 months ago

Hi, core-js team. Thank you for developing this great library.

Background

packages/core-js-pure/override/modules/web.dom-collections.iterator.js sets writable of Symbol.toStringTag property of DOM Iterables as true. That is because createNonEnumerableProperty() defines PropertyDescriptor with writable: true.

As a result, the presence or absence of core-js affects some systems whose behavior changes depending on the writable value. For example, this part of lodash will be affected.

Question

  1. What is the reason for overwrite of the writable value of Symbol.toStringTag property of DOM Iterables? (I'm thinking about patching to stop this overwrite on my application using core-js. Of course, if I can help anything, I'd like to contribute to core-js also.)
  2. This file, packages/core-js-pure/override/modules/web.dom-collections.iterator.js, is in core-js-pure. I've thought that core-js will never overwrite prototypes. It's not correct??
zloirock commented 6 months ago

Thanks, you are right, they should be non-writable.

Could you show for what collections and in what engines they are defined? With the current logic, they should be defined only in case of lack or inconsistency @@toStringTag on DOM collections prototypes.

canalun commented 6 months ago

Thanks :)

I checked by using the below page. https://codesandbox.io/p/sandbox/determined-bose-sk7wqw

zloirock commented 6 months ago

Ok, thanks, here is a wrong condition.

zloirock commented 6 months ago

classof(CollectionPrototype) !== TO_STRING_TAG instead of classof(CollectionPrototype) !== COLLECTION_NAME

canalun commented 6 months ago

Got it, thanks :) I'll try to patch it!

zloirock commented 6 months ago

Here also required some other changes, I already made them -)

canalun commented 6 months ago

wow, really thanks...!! I'm trying it on my environment now :)

canalun commented 6 months ago

The problem has been resolved, thank you so much for your quick response! ! !