polyfills icon indicating copy to clipboard operation
polyfills copied to clipboard

Use Object.defineProperty instead direct define when create polyfilled HTMLCollection

Open louielin opened this issue 5 years ago • 7 comments

Direct define would cause enumerable issue. This behavior may break some js lib.

Object.keys(document.querySelectorAll('body'));
// 0, item, namedItem

var buttons = document.querySelectorAll('button');
Object.keys(buttons).forEach(function(i) {
    var button = buttons[i];
    button.addEventListener(/*...*/); // raise error when "i" is "item" or "namedItem"
);

Using Object.defineProperty and ensure enumerable equal to false will let "item" and "namedItem" methods disappear in Object.keys and for loop

louielin avatar Aug 24 '20 09:08 louielin

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot avatar Aug 24 '20 09:08 googlebot

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot avatar Aug 24 '20 09:08 googlebot

@googlebot I signed it!

@googlebot I signed it!

louielin avatar Aug 24 '20 09:08 louielin

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

googlebot avatar Aug 24 '20 09:08 googlebot

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

googlebot avatar Aug 24 '20 09:08 googlebot

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 16 '21 07:10 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 19 '22 05:10 stale[bot]