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

[v4] [icons] fix: pre-es2017 compatibility #5098

Closed
wants to merge 1 commit into from
Closed

Conversation

gluxon
Copy link
Contributor

@gluxon gluxon commented Jan 16, 2022

Fixes #5097

Changes proposed in this pull request:

Switches an Object.values usage to a for ... in ... loop for pre-es2017 browser compatibility.

Reviewers should focus on:

Edit: The guard-for-in ESLint rule triggered on the below. Updated the commit for propertyIsEnumerable.

According to MDN, Object.values also filters on own enumerable properties, so technically we should also check for Object.prototype.propertyIsEnumerable().

TypeScript doesn't seem to generate non-own enumerable properties for enum objects though, so in practice the extra check isn't needed. https://www.typescriptlang.org/play?#code/KYOwrgtgBAYg9nKBvAsAKCpqAhAhgJygF4oAiAIwNPQF910AzOQgCgGM4QBnAFygGtgATygBLELAQBKZOixQO3OABtgAOmVwA5i0FCptIA

Happy to add it if reviewers think the extra soundness is worthwhile.

@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @gluxon! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@gluxon gluxon changed the title [icons] fix: pre-es2017 compatibility [v4] [icons] fix: pre-es2017 compatibility Jan 16, 2022
@gluxon
Copy link
Contributor Author

gluxon commented Jan 16, 2022

Did a quick smoke test to make sure this didn't affect the contents of IconNames.

cd packages/icons

# Before
❯ git reset --hard ORIG_HEAD
HEAD is now at 4dac1637 Publish
❯ node -e 'console.log(Object.keys(require("./lib/cjs/iconNames").IconNames).length)'
1078
❯ node -e 'console.log(require("./lib/cjs/iconNames"))' | md5sum
8cb0237c9ed0ff2db4679aed00f76a00  -

# After
❯ git reset --hard ORIG_HEAD
HEAD is now at 1bcd43e7 [v4] [icons] fix: pre-es2017 compatibility
❯ yarn compile  
❯ node -e 'console.log(Object.keys(require("./lib/cjs/iconNames").IconNames).length)'
1078
❯ node -e 'console.log(require("./lib/cjs/iconNames"))' | md5sum
8cb0237c9ed0ff2db4679aed00f76a00  -

@gluxon gluxon marked this pull request as ready for review January 16, 2022 00:36
@gluxon gluxon requested a review from adidahiya January 18, 2022 15:38
Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

Since we already require a few modern language features to use Blueprint (including a few which are not fully supported in IE11 and thus require polyfills), I'd rather take a different approach.

Rather than add backwards-compatible code for IE11, let's instead update the docs to indicate that Object.values() support is now required at runtime with Blueprint v4.0. Users can polyfill it with core-js.

We are planning to completely remove support for IE11 anyway soon (I'll add a deprecation notice to the docs before the v4.0 stable release).

@gluxon
Copy link
Contributor Author

gluxon commented Jan 18, 2022

Sounds good to me. Thanks for taking a look @adidahiya. 🙂

@gluxon gluxon closed this Jan 18, 2022
@gluxon gluxon deleted the next branch January 18, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants