Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many polyfills are missing #1113

Open
chenyulun opened this issue Nov 10, 2021 · 2 comments
Open

Many polyfills are missing #1113

chenyulun opened this issue Nov 10, 2021 · 2 comments
Labels
library Relates to an Origami library

Comments

@chenyulun
Copy link

[type]: A bug report

What

Core-js test cases are compared,It turns out that Polyfill-Library is missing a lot

Details

Chrome 41
https://github.com/chenyulun/polyfill-test

polyfill-test

polyfill.io VS core-js3.9.1

Use the link calculated below

 const featuresList = [
  'default',
  'es2015',
  'es2016',
  'es2017',
  'es2018',
  'es2019',
  'es2020',
  'es2021',
  'globalThis',
  'queueMicrotask',
  // 'URL',
  'URL.prototype.toJSON',
  'URLSearchParams',
  // 'DOMTokenList',
  'DOMTokenList.prototype.@@iterator',
  'DOMTokenList.prototype.forEach',
  'DOMTokenList.prototype.replace',
  'NodeList.prototype.@@iterator',
  'NodeList.prototype.forEach',
  'URL.prototype.toJSON',
  'URLSearchParams',
  'Reflect',
  'Reflect.apply',
  'Reflect.construct',
  'Reflect.defineProperty',
  'Reflect.deleteProperty',
  'Reflect.get',
  'Reflect.getOwnPropertyDescriptor',
  'Reflect.getPrototypeOf',
  'Reflect.has',
  'Reflect.isExtensible',
  'Reflect.ownKeys',
  'Reflect.preventExtensions',
  'Reflect.set',
  'Reflect.setPrototypeOf',
  // 'setImmediate',
]
const features = encodeURIComponent(featuresList.join(','))
console.log(`https://polyfill.io/v3/polyfill.min.js?features=${features}`)
// https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015%2Ces2016%2Ces2017%2Ces2018%2Ces2019%2Ces2020%2Ces2021%2CglobalThis%2CqueueMicrotask%2CURL.prototype.toJSON%2CURLSearchParams%2CDOMTokenList.prototype.%40%40iterator%2CDOMTokenList.prototype.forEach%2CDOMTokenList.prototype.replace%2CNodeList.prototype.%40%40iterator%2CNodeList.prototype.forEach%2CURL.prototype.toJSON%2CURLSearchParams%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.get%2CReflect.getOwnPropertyDescriptor%2CReflect.getPrototypeOf%2CReflect.has%2CReflect.isExtensible%2CReflect.ownKeys%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf

Core-js compiles the full code minified.js

The patch gap in the lower version of the phone is too big

Test steps

~ yarn
~ yarn http-server -p 8085 -c-1

Choose a lower version of Chrome /41

Open a browser to http://ip:8085/tests/index.html

  1. Add the core - js - 3.19.1
    open file tests/index.html
+ <script src='./minified.js'></script>
<script src='./tests.js'></script>

You can see it's basically all green

  1. add polyfill.io
    tests/index.html
- <script src='./minified.js'></script>
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015%2Ces2016%2Ces2017%2Ces2018%2Ces2019%2Ces2020%2Ces2021%2CglobalThis%2CqueueMicrotask%2CURL.prototype.toJSON%2CURLSearchParams%2CDOMTokenList.prototype.%40%40iterator%2CDOMTokenList.prototype.forEach%2CDOMTokenList.prototype.replace%2CNodeList.prototype.%40%40iterator%2CNodeList.prototype.forEach%2CURL.prototype.toJSON%2CURLSearchParams%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.get%2CReflect.getOwnPropertyDescriptor%2CReflect.getPrototypeOf%2CReflect.has%2CReflect.isExtensible%2CReflect.ownKeys%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf"></script>
<script src='./tests.js'></script>

Ignore esNext, Many polyfills are defective,Especially when it comes to symbols
example

new URL('http://a#б').hash === '#%D0%B1' // chrome95 and core-js:true polyfill.io: false
1 / [1].indexOf(1, -0) > 0 // chrome95 and core-js: true polyfill.io: false
new Int8Array(null) // 
[].at //
Array.prototype[Symbol.unscopables].find //
@origamiserviceuser origamiserviceuser added this to incoming in Origami ✨ Nov 10, 2021
@github-actions github-actions bot added the library Relates to an Origami library label Nov 10, 2021
@mhassan1
Copy link
Collaborator

i think it would be helpful to have individual issues for each of these defective polyfills, with the appropriate level of detail. i would be happy to help pick up some of that work.

@zloirock
Copy link

@chenyulun if you wanna use core-js test suite, it's much better to use /tests/tests instead of /tests/compat since /tests/compat is oriented only to detection of basic and known issues of native implementations.

@robertboulton robertboulton removed this from Backlog in Origami ✨ Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library Relates to an Origami library
Projects
None yet
Development

No branches or pull requests

3 participants