Skip to content

Conversation

@timmywil
Copy link
Member

@timmywil timmywil commented May 6, 2015

+22 bytes. You may or may not be surprised that this is actually faster overall.

Fixes gh-2199

@mgol
Copy link
Member

mgol commented May 6, 2015

It's not faster for me. Not slower either, though.
screen shot 2015-05-06 at 22 48 41
screen shot 2015-05-06 at 22 50 45

LGTM, a lot of people are asking for this.

@timmywil
Copy link
Member Author

timmywil commented May 6, 2015

Interesting you got different results than me. I'm glad it's not a perf hit, though.

@timmywil
Copy link
Member Author

timmywil commented May 6, 2015

@mzgol Oh, you got different results because I accidentally built on master and pushed master to dropbox. Please have a look again.

@mgol
Copy link
Member

mgol commented May 10, 2015

Indeed, now it looks faster. No +1 but +2 then ;)

@timmywil
Copy link
Member Author

@dmethvin Let's add this to the blog post! 😺

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need elem.getAttribute && bit?

Copy link
Member

Choose a reason for hiding this comment

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

Even if we need it, maybe ternary would be better -

elem.getAttribute ? elem.getAttribute( "class" ) : ""

then && & || magic

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the check because we have tests supporting some silent fails. The proposed alternative differs in logic. This way still returns an empty string in the case where getAttribute does not exist.

Copy link
Member

Choose a reason for hiding this comment

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

We need the check because we have tests supporting some silent fails

Could you post the link?

This way still returns an empty string in the case where getAttribute does not exist.

Oh, same returned type, okay, cool

Copy link
Member Author

Choose a reason for hiding this comment

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

I realised I said that wrong, but you got what I meant. getAttribute can return null and this ensures we return a string.

Copy link
Member

Choose a reason for hiding this comment

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

I realised I said the wrong, but you got what I meant. getAttribute can return null and this ensures we return a string.

Aaam, if you said something wrong, i didn't notice :-), i meant it is good if some function always returns the same type.
I wondering about what tests we wouldn't pass though, if it would be just elem.getAttribute( "class" ) || ""?

Copy link
Member Author

Choose a reason for hiding this comment

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

- Note: support for SVG is limited in jQuery,
  but this is one area where the cost vs benefit ratio
  was acceptable.

Fixes jquerygh-2199
@timmywil timmywil closed this in 20aaed3 May 12, 2015
timmywil added a commit that referenced this pull request May 12, 2015
- Note: support for SVG is limited in jQuery,
  but this is one area where the cost vs benefit ratio
  was acceptable.

Fixes gh-2199
Close gh-2268
@timmywil timmywil deleted the 2199-svg branch May 12, 2015 14:25
mgol added a commit to mgol/jquery that referenced this pull request May 18, 2015
mgol added a commit to mgol/jquery that referenced this pull request May 18, 2015
mgol added a commit to mgol/jquery that referenced this pull request May 18, 2015
timmywil added a commit that referenced this pull request Nov 10, 2015
- Note: support for SVG is limited in jQuery,
  but this is one area where the cost vs benefit ratio
  was acceptable.

Fixes gh-2199
Close gh-2268
@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.

jQuery Class Operations on SVG DOM Attributes

4 participants