Skip to content

Polyfill Element#getAttributeNames. #393

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

Merged
merged 6 commits into from
Oct 16, 2020
Merged

Polyfill Element#getAttributeNames. #393

merged 6 commits into from
Oct 16, 2020

Conversation

bicknellr
Copy link
Collaborator

@bicknellr bicknellr commented Oct 12, 2020

Adds a polyfill for Element#getAttributeNames.

@bicknellr bicknellr marked this pull request as ready for review October 13, 2020 00:47
@bicknellr bicknellr requested a review from aomarks as a code owner October 13, 2020 00:47
@bicknellr
Copy link
Collaborator Author

@justinfagnani, isn't there some attribute ordering problem with IE11? Does this polyfill need to address that?

@justinfagnani
Copy link
Collaborator

@justinfagnani, isn't there some attribute ordering problem with IE11? Does this polyfill need to address that?

There's no way to address this since the ordering is lost during parsing. We're already robust to ordering changes when using .attributes though, so we're ok here.


if (!Element_prototype.hasOwnProperty('getAttributeNames')) {
Element_prototype.getAttributeNames = function getAttributeNames(this: Element): Array<string> {
return map.call(getAttributes.call(this), attr => attr.name) as Array<string>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of storing the .attributes getter, why not just call this.attributes here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just so that this won't call into anything else that might wrap the attributes getter after this polyfill is applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants