-
Notifications
You must be signed in to change notification settings - Fork 834
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
Remove IE11-specific code #4603
Conversation
Since IE11 is not supported anymore.
/** | ||
* 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; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method (containing IE11 specific code) was not used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
* Remove unused method * Refactor IE11-specific code Since IE11 is not supported anymore.
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 test
succeeds 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.