Skip to content

Attributes: Fixed Coding Convention #3221

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

Closed
wants to merge 1 commit into from

Conversation

mixed
Copy link
Contributor

@mixed mixed commented Jul 6, 2016

Summary

Properties should check undefined using object.prop === undefined.
https://contribute.jquery.org/style-guide/js/#type-checks

Checklist

Mark an [x] for completed items, if you're not sure leave them unchecked and we can assist.

Thanks! Bots and humans will be around shortly to check it out.

Sorry, something went wrong.

@@ -34,7 +34,7 @@ jQuery.extend( {
}

// Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === "undefined" ) {
if ( elem.getAttribute === undefined ) {
Copy link
Member

Choose a reason for hiding this comment

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

This was intentional, but probably not needed anymore. @jquery/core Does anyone remember at what point IE stopped automatically invoking the method on mere reference?

Copy link
Member

Choose a reason for hiding this comment

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

Either IE7 or IE8, so we should be in the clear.

Copy link
Member

Choose a reason for hiding this comment

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

It was only certain properties in IE8, but I think we're safe now. We could probably do just...

if ( !elem.getAttribute ) {

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it violate our code style?

Copy link
Member

Choose a reason for hiding this comment

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

Also, pretty sure we added tests for that, so if they pass we should definitely be in the clear

Copy link
Member

@timmywil timmywil Jul 8, 2016

Choose a reason for hiding this comment

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

Wouldn't it violate our code style?

Sure, we can change it, tho. Those styles were decided based on what we needed to do for old IE.

Copy link
Member

Choose a reason for hiding this comment

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

Do you wanna? :)

Copy link
Member

Choose a reason for hiding this comment

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

I do, as long as we no longer have to use typeof.

Copy link
Member

Choose a reason for hiding this comment

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

To conclude: we still need typeof in some places for all IE versions as it still has the auto-invoking problem for some host objects: https://github.com/jquery/jquery/blob/e4fd41f/src/manipulation/getAll.js#L10

@markelog
Copy link
Member

markelog commented Jul 8, 2016

Added correspondent ticket for eslint config - jquery/eslint-config-jquery#5

@timmywil
Copy link
Member

Since we should make a sweep across the whole repo, and the check will probably not look like the one proposed here, I'll close this PR. Added to Roadmap.

@timmywil timmywil closed this Jul 13, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants