Merged
Conversation
Since IE11 is not supported anymore.
Frank3K
commented
Dec 20, 2023
Comment on lines
-209
to
-236
| /** | ||
| * Returns the first key in a Map in iteration order. | ||
| * | ||
| * NOTE(cdata): This is necessary because IE11 does not implement iterator | ||
| * methods of Map, and polymer-build does not polyfill these methods for | ||
| * compatibility and performance reasons. This helper proposes that it is | ||
| * a reasonable compromise to sacrifice a very small amount of runtime | ||
| * performance in IE11 for the sake of code clarity. | ||
| */ | ||
| export const getFirstMapKey = <T = any, U = any>(map: Map<T, U>): T|null => { | ||
| if (map.keys != null) { | ||
| return map.keys().next().value || null; | ||
| } | ||
|
|
||
| let firstKey: T|null = null; | ||
|
|
||
| try { | ||
| map.forEach((_value: U, key: T, _map: Map<T, U>) => { | ||
| firstKey = key; | ||
| // Stop iterating the Map with forEach: | ||
| throw new Error(); | ||
| }); | ||
| } catch (_error) { | ||
| } | ||
|
|
||
| return firstKey; | ||
| }; | ||
|
|
Contributor
Author
There was a problem hiding this comment.
This method (containing IE11 specific code) was not used anymore.
elalish
approved these changes
Dec 20, 2023
Contributor
elalish
left a comment
There was a problem hiding this comment.
Excellent, thank you for the cleanup! I wouldn't be surprised if there are more of these lurking, though I try to remove them whenever I notice them.
JL-Vidinoti
pushed a commit
to vidinoti/model-viewer
that referenced
this pull request
Apr 22, 2024
* Remove unused method * Refactor IE11-specific code Since IE11 is not supported anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
While browsing through the code, I found some IE11-specific code. Since IE11 is not a supported browser anymore (by model-viewer's README), nor by three.js, I think this code can be refactored to more modern code. This change leads to a somewhat smaller bundle size.
Bundle size
File size after a
npm run build:Testing
npm run testsucceeds on my local machine.UMD bundles
In the rollup config I found this code:
model-viewer/packages/model-viewer/rollup.config.js
Lines 73 to 83 in 99fa9a8
If I understand correctly this is not just for IE11, but for any browser that does not support ES Modules. The specific lines were introduced in 92111b3. Since all modern / supported browsers support ES6 Modules (caniuse), I doubt if the UMD bundles are still required. I do not see any usage of the umd bundles in the repository itself (e.g. in the aforementioned unit test build).
Because I am not sure, I did not touch the rollup config.