-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Fixing ng-jq issue with getNgAttribute #11044
Conversation
@Narretz I agree that we should add e2e tests, but I find the current way of Angular doing e2e tests fairly confusing to understand and I haven't found much documentation on such. Plus, I'm not sure how to setup the test in a fresh page that already has ng-jq predefined before Angular loads. Any direction in this would be very helpful. |
First of all, I think this is the totally wrong approach to solving this issue. The issue is about using the jquery api within For e2e testing, there is a sample test in There isn't much of a guide, but it should be simpler than writing docs e2e tests. I am happy to review and give pointers on writing the test(s) next week. |
name = el.getAttribute(prefix + 'jq'); | ||
} | ||
|
||
return (jq.name_ = name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation...
(Again... 😸)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
god damn spaces...
Thanks @caitp, I'll definitely add that in. I would be keen to change the getNgAttribute function to not use jquery api and I agree with it as well since it's a dependency on an object that we don't know when it'll be available. However, I didn't want to change it in case there's a particular use case needed for it and I don't know the angular project enough to make my own decision on this. @Narretz Will definitely add e2e tests, but in the meantime, can we merge this to fix the issue? |
@mboudreau: Since you seem to have fixed |
@gkalpak I was thinking about it, but since I am already searching for ng-jq through the prefixes, I didn't see the point of doing another loop through all the prefixes if I already know it. I'll leave it up to you if that's a good idea, but figured it was only 1 loop through the prefixes that's needed, not 2. |
@mboudreau, either way is fine, I guess. It's micro-optimizing performance vs micro-optimizing readability, so it's just a matter of taste :) |
@gkalpak You make a good point, but it's not that hard to understand, just not using the helper function to make it 'easier'. I'd take a readability hit for a performance gain on that unless someone on the angular team has a really big issue with it. |
I'll see it like @gkalpak - I prefer |
I'm looking into e2e test now. We can't merge this atm - we raelly only want to merge with tests. |
New PR in #11182 |
The unit tests wasn't able to catch this unless it's on a 'fresh' angular page with ng-jq already added before angular bootstrapping. I've removed the need for jq() to rely on getNgAttribute and instead using element.getAttribute function with the found prefix.
Could use some direction on how to test ng-jq more thoroughly so this doesn't happen again in the future.
This fixes issue #11016.