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

fix(jqLite): fix add/remove class in IE9 #9474

Closed
wants to merge 1 commit into from

Conversation

btford
Copy link
Contributor

@btford btford commented Oct 7, 2014

IE is not my favorite web browser.

this is my take on #5694

Condensed logic, changed toEqual to toBe
@jeffbcross
Copy link
Contributor

Thanks for your submission, @btford. I will give this a thorough review.

@jeffbcross jeffbcross self-assigned this Oct 7, 2014
@btford
Copy link
Contributor Author

btford commented Oct 7, 2014

You are very welcome Jeff Brian Cross. I look forward to your continued help in landing this PR.

@btford btford added this to the 1.3.0-rc.5 milestone Oct 7, 2014
});

(msie === 9 && !(element instanceof SVGElement)) ? element.className = trim(existingClasses) :
Copy link
Contributor

Choose a reason for hiding this comment

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

does IE9 parse classes when the attribute is set for SVG elements but not for other elements? (I know className is an object in SVG, but it's weird that this is necessary at all). Would this break SVG class operations for IE9?

In either case, there is a lot of branching happening in this function, what if we just had two versions of the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what if we just had two versions of the function?

Considered it; this would also make it easy to drop support for IE9 in the future. Let me put together an alternate PR and see what that looks like.

@caitp
Copy link
Contributor

caitp commented Oct 7, 2014

PS #5001 (comment)

@@ -836,6 +845,17 @@ describe('jqLite', function() {
});


it('should allow removal of class in IE9', function() {
if (!(jqLite(a).setAttribute && jqLite(a).getAttribute)) return; // IE9 doesn't support node.setAttribute
Copy link
Contributor

Choose a reason for hiding this comment

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

According to http://msdn.microsoft.com/en-us/library/ie/ms536739(v=vs.85).aspx,

Windows Internet Explorer 8 and later. IE8 Standards mode enables several enhancements to the setAttribute, getAttribute, and removeAttribute methods that are not available when pages are displayed in earlier document modes.

Copy link
Contributor

Choose a reason for hiding this comment

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

but besides that, jqLite(a) is gonna be a jQuery/jqLite object --- so it's not going to have getAttribute or setAttribute anyways, only attr()

@jeffbcross
Copy link
Contributor

I agree with @caitp

@btford
Copy link
Contributor Author

btford commented Oct 7, 2014

thanks jeff

@caitp
Copy link
Contributor

caitp commented Oct 7, 2014

I've tried a few variations on SL, this was the only one I could make work consistently for SVG and non-SVG: http://jsbin.com/cidubareyuko/1/edit (although in reality, we don't need to use classList for SVG, because we can use className.baseVal instead --- this would be a lot simpler)

@jeffbcross jeffbcross force-pushed the master branch 2 times, most recently from abdaab7 to 30996f8 Compare October 8, 2014 19:47
@IgorMinar
Copy link
Contributor

closing per #5001 (comment)

@IgorMinar IgorMinar closed this Oct 8, 2014
@btford btford removed the In Progress label Oct 8, 2014
@caitp
Copy link
Contributor

caitp commented Oct 8, 2014

I sort of disagree with the perf thing, I think we could do this, the real cost is an extra 5-10 lines of code. It's not free, but this should be doable.

An alternative to this would be removing support for the weird xml-namespace-ish syntax, wdyt?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants