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

nextElementSibling, previousElementSibling polyfills #338

Closed
NickColley opened this issue Dec 11, 2019 · 9 comments · Fixed by #484
Closed

nextElementSibling, previousElementSibling polyfills #338

NickColley opened this issue Dec 11, 2019 · 9 comments · Fixed by #484

Comments

@NickColley
Copy link
Contributor

Hey folks,

We are using nextElementSibling and previousElementSibiling polyfills that were in the polyfill-service library, but they don't seem to be in the new repo.

Is there any documentation why this is? I would be interested in adding these back to this version if you'd be interested too.

https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-b45a1197b842728cb76b624b6ba7d739

@JakeChampion
Copy link
Owner

Hi, I'm not sure how we lost those polyfills, sorry about that 😔

We would be interested in getting them added back.

Are you able to submit a pull-request which adds them?

@NickColley
Copy link
Contributor Author

NickColley commented Feb 24, 2020

Yeah :) Do you have any guidelines or perhaps a pull request that demonstrates a good example of adding something? Otherwise I can figure it out...

@NickColley
Copy link
Contributor Author

@JakeChampion
Copy link
Owner

Browser support:
https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode/nextElementSibling#Browser_Compatibility

We would create a new folder inside ./polyfills/Node/prototype named nextElementSibling and create 4 files within this folder:
polyfill.js -- The polyfill code itself
detect.js -- An expression which detects if nextElementSibling exists in the user-agent ( "nextElementSibling" in Node.prototype would be a good expression to use)
config.toml -- The configuration which states any dependencies the polyfill has on other features/polyfills and what user-agents/browsers need the polyfill
tests.js -- A test suite to prove the polyfill works correctly

The specification for the feature is here -- https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling

Some tests already exist for this feature within the web-platform-tests projects, we should/could base our tests off of those ones. https://github.com/web-platform-tests/wpt/blob/master/dom/nodes/Element-nextElementSibling.html

A good folder in this project to look at if unsure about what to do would be requestIdleCallback https://github.com/Financial-Times/polyfill-library/tree/master/polyfills/requestIdleCallback which @notlee contributed.

@NickColley
Copy link
Contributor Author

NickColley commented Feb 24, 2020

Thanks 💌

@JakeChampion
Copy link
Owner

If you have any questions, please comment on this issue and I will do my best to help :-)

@NickColley
Copy link
Contributor Author

@JakeChampion is there any documentation on the syntax of the browser support in the toml file vs MDN. They don't seem to be aligned at the moment, I'm not sure what the wildcard indicates at the moment for example.

@NickColley
Copy link
Contributor Author

I've opened a draft pull request that we can continue the discussion on, thanks for your help so far.

@JakeChampion
Copy link
Owner

@NickColley the string in config.toml.browsers are SemVer ranges. The * is the SemVer range for any version.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants