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

Polyfill replaceChildren #81

Merged
merged 3 commits into from
Nov 23, 2021
Merged

Polyfill replaceChildren #81

merged 3 commits into from
Nov 23, 2021

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Nov 23, 2021

replaceChildren is not supported on older browsers. See https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren#browser_compatibility

This PR uses the polyfill from https://github.com/yuzhe-han/ParentNode-replaceChildren in cases where replaceChildren is unavailable.

@danjm danjm requested a review from a team as a code owner November 23, 2021 17:48
util.js Outdated Show resolved Hide resolved
util.js Outdated
@@ -7,6 +7,18 @@ const transform = require('gl-vec3/transformMat4');

const SVG_NS = 'http://www.w3.org/2000/svg';

// Taken from https://github.com/yuzhe-han/ParentNode-replaceChildren
// This is to support browsers that do not yet support `replaceChildren`
const replaceChildrenPolyfill = function (...addNodes) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: since this isn't being attached to Node.prototype.replaceChildren, it might be more correct to call this a "ponyfill".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 1b0a00b

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@danjm danjm merged commit 73d3cd8 into main Nov 23, 2021
@danjm danjm deleted the polyfill-replaceChildren branch November 23, 2021 23:40
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.

2 participants