Skip to content

Conversation

@pgilad
Copy link
Contributor

@pgilad pgilad commented Jun 10, 2015

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

The !elem check is unnecessary see #2201

Copy link
Member

Choose a reason for hiding this comment

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

The lack of this guard in jQuery.attr is a behavior difference with respect to jQuery.prop since 55ac56a, and if anything the latter should be brought in line (since we read elem.nodeType prior to it, we've already thrown if elem is null or undefined). See also #2320.

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

Copy link
Member

Choose a reason for hiding this comment

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

This variable might not be benefiting us in either method. I'd check the impact of removing it.

@gibson042
Copy link
Member

This is good (-35 min+gz). Can you also look at increasing the return similarities (from value !== undefined onward)?

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

@gibson042 No problem.

Regarding checking if elem exists (in either prop or attr). What are the thoughts?

@gibson042
Copy link
Member

Regarding checking if elem exists (in either prop or attr). What are the thoughts?

Drop it from both.

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

Ok rebased what was noted so far... Will continue trying to create similarities...

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

@gibson042 I think the module selector-sizzle is missing in prop.js (but found in attr.js )- we use jQuery.isXMLDoc (https://github.com/jquery/jquery/blob/master/src/attributes/prop.js#L36)

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

There is also an inconsistency where in prop( someKey, null ) - the null will get assigned and in attr( someKey, null ) is translated to jQuery.removeAttr.

Is there are reason for that?

edit I now see that in attr the value gets coerced into a string. I don't think that the remove behavior is documented though. Either way I think the behavior should be consistent between them.

Relevant code: https://github.com/jquery/jquery/blob/master/src/attributes/attr.js#L49-L50

@gibson042
Copy link
Member

I think the module selector-sizzle is missing in prop.js (but found in attr.js )- we use jQuery.isXMLDoc (https://github.com/jquery/jquery/blob/master/src/attributes/prop.js#L36)

What do you mean? That method is provided by selector, which is part of the minimum build set.

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

I mean "../selector" is imported in attr.js but not in prop.js even though they both use the method isXMLDoc found in selector-sizzle.

@gibson042
Copy link
Member

There is also an inconsistency where in prop( someKey, null ) - the null will get assigned and in attr( someKey, null ) is translated to jQuery.removeAttr.

Is there are reason for that?

It is intentional, but surprisingly not documented! That inconsistency should be preserved by this pull request, as should the string coercion in attr. DOM attributes are an inherently less powerful data store than Javascript properties.

@gibson042
Copy link
Member

Ah. prop.js should also import ../selector.

@pgilad
Copy link
Contributor Author

pgilad commented Jun 10, 2015

@gibson042 Great... I think I implemented all of the changes. Also flattened the multiple nested ifs (I highly dislike the nested ifs and prefer the early returns.

@markelog
Copy link
Member

@pgilad we're ready to land this, but could you also provide a pull for the compat branch? Otherwise it would be hard for us to port these changes in there

@pgilad
Copy link
Contributor Author

pgilad commented Jun 23, 2015

@markelog Done - #2426
Also rebased this PR against master

@markelog markelog closed this in 5153b53 Jun 23, 2015
@markelog
Copy link
Member

Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 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.

5 participants