Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

#5001: Fixes jqLite not correctly adding & removing classes in IE9 #5694

Closed

Conversation

wesleycho
Copy link
Contributor

This PR is a cleaned up version of #5686. This is for #5001.

Somehow my history got polluted due to bouncing between two different computers.

@tbosch
Copy link
Contributor

tbosch commented Jan 10, 2014

Hi,
your build is failing as it does not conform with our jshint rules.
To check locally, type grunt jshint.

@tbosch
Copy link
Contributor

tbosch commented Jan 10, 2014

And your tests should run in all browsers, so no need to check for ie there in specific!

@wesleycho
Copy link
Contributor Author

Hm, but I am testing for an IE specific issue - should I have not written that particular unit test then? The one just prior should presumably catch all cases, but for some reason it misses the problem with IE9. I'm not quite sure how to write the appropriate test given that the current one seems to miss this bug

@tbosch
Copy link
Contributor

tbosch commented Jan 10, 2014

What we need: A unit test that fails without your patch but works with it.
So what is the issue in IE9 exactly? Does it not have the node.setAttribute method?
If you know the exact problem, you should be able to write a unit test for it...

@@ -579,6 +579,14 @@ describe('jqLite', function() {
expect(jqLite(b).hasClass('abc')).toEqual(true);
});

it('should allow adding of class in IE9', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the issue was reported as only affecting nodes that had both ng:class and ng:click directives in that xml style, or maybe some combination of similar circumstances.

Does this patch fix that? If so, that's probably what should be tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually turns out to be a broader issue - I'm not sure why it fails only in this particular case. ng:class fails alone without ng-click or ng:click.

@wesleycho
Copy link
Contributor Author

Alright, I'll go through those steps next week to verify 100% & clean up the PR with a rebase - I'm out of commission until Monday, but I believe I have a fix.

I do want to do some more investigation though, because I suspect usage of ng:class in IE8 also fails. Is there any reason why this error would only pop up for usage of ng:class and not ng-class in IE9? This difference bewilders me.

@wesleycho
Copy link
Contributor Author

I believe this PR is good for a review now.

@@ -312,7 +313,7 @@ function jqLiteRemoveClass(element, cssClasses) {

function jqLiteAddClass(element, cssClasses) {
if (cssClasses && element.setAttribute) {
var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
var existingClasses = (' ' + ((element.getAttribute ? element.getAttribute('class') : element.className) || '') + ' ')
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't take this comment too seriously, since it's already been pointed out that jQuery doesn't worry about this either, but this is going to cause issues for SVG elements, where the className is an object.

@wesleycho
Copy link
Contributor Author

@caitp I think I fixed all of the tests that my change broke - the current master has broken tests though due to something fishy going on with $animate and ngRoute though.

Edit: Nevermind, must've been something weird going on locally. This PR is solid test-wise now with suggested changes.

@btford btford modified the milestones: 1.3.0-beta.1, Backlog, 1.3.0-beta.2 Mar 4, 2014
@tbosch tbosch modified the milestones: 1.3.0-beta.3, 1.3.0-beta.2 Mar 14, 2014
@btford btford modified the milestones: 1.3.0-beta.4, 1.3.0-beta.3 Mar 24, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.0-beta.6, 1.3.0-beta.5 Apr 3, 2014
@btford btford assigned btford and unassigned matsko Apr 7, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-beta.7, 1.3.0-beta.6 Apr 22, 2014
@caitp caitp modified the milestones: 1.3.0-beta.9, 1.3.0-beta.8 May 9, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0, 1.3.0-beta.9 May 12, 2014
@btford btford removed the gh: PR label Aug 20, 2014
Wesley Cho and others added 3 commits August 28, 2014 22:35
@btford
Copy link
Contributor

btford commented Oct 6, 2014

This fix seems to work for adding classes, but not for removing them.

@btford
Copy link
Contributor

btford commented Oct 8, 2014

See #5001 (comment)

@btford btford closed this Oct 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants