paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 388 forks source link

Fix crash when `target`(in Value.preserveToString) is undefined #470

Closed gnh1201 closed 3 years ago

gnh1201 commented 3 years ago

https://github.com/paulmillr/es6-shim/issues/467

codecov-commenter commented 3 years ago

Codecov Report

Merging #470 (d00ef8f) into master (8d44bc1) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #470   +/-   ##
=======================================
  Coverage   86.05%   86.05%           
=======================================
  Files           2        2           
  Lines        2352     2352           
  Branches      607      607           
=======================================
  Hits         2024     2024           
  Misses        328      328           
Impacted Files Coverage Δ
es6-shim.js 87.57% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8d44bc1...d00ef8f. Read the comment docs.

gnh1201 commented 3 years ago
* typeof(globals.Reflect): object
* typeof(ReflectShims.defineProperty): undefined   <-- error
overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty);

This means that globals.Reflect variable is going to be undefined.

How can I fix a problem that ReflectShims.defineProperty is undefined?

ljharb commented 3 years ago

Ah - if Reflect exists but Reflect.defineProperty does not, then that block of code should do branch, and call defineProperty versus overrideNative.

gnh1201 commented 3 years ago

Found a better solution.

ljharb commented 3 years ago

@gnh1201 what better solution? Is #467 still an issue?