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

ngClass bug with ng:class and ng:click on one element #5001

Closed
sja opened this issue Nov 18, 2013 · 12 comments
Closed

ngClass bug with ng:class and ng:click on one element #5001

sja opened this issue Nov 18, 2013 · 12 comments

Comments

@sja
Copy link

sja commented Nov 18, 2013

If you have ngClass and ngClick directive on one element and write them as ng:class=... and ng:click=..., the class attribute will always be empty.

Example: http://plnkr.co/edit/t66oOw

@btford
Copy link
Contributor

btford commented Jan 3, 2014

I see the plunker is entitled "IE bug." What version of IE?

@sja
Copy link
Author

sja commented Jan 3, 2014

It's IE9.
IE8 and IE10 work.
By the way: You cannot use plunker itself to test, because it won't load in IE9. You have to put the downloadable ZIP-Contant in a served folder and load it from there. The reason behind are the IE Security Zones which are a bit strange on local files (IE will ask you to allow execution of ActiveX-Scripts, which seems to be Angular because I linked the CDN-URL).
Update: This would be easier for you: http://jnzn.de/plunk-t66oOw/ :-)

@IgorMinar
Copy link
Contributor

@wesleycho would you like to take a look at this one?

@wesleycho
Copy link
Contributor

Sure, I can take a stab at it.

@IgorMinar IgorMinar removed this from the 1.3.0-beta.6 milestone 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: issue label Aug 20, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-rc.5, 1.3.0 Oct 1, 2014
@caitp
Copy link
Contributor

caitp commented Oct 7, 2014

BTW: just testing this on SL, I can make the original plunker work by not using the XML namespace-style notation, but instead ng-class / ng-click / ng-app.

Could be that the namespace-style just breaks it?

@btford
Copy link
Contributor

btford commented Oct 7, 2014

Could be that the namespace-style just breaks it?

yes. the namespace seems to affect the presence of getAttribute/setAttribute

@caitp
Copy link
Contributor

caitp commented Oct 7, 2014

http://jsbin.com/mihularemobu/1/edit in SL / IE9, typeof setAttribute and getAttribute are function regardless of whether a namespaced attribute is used --- it's probably just the behaviour ofthe functions that break.

I don't think there's much we can do about that though, unless we come up with some hack that uses the attributes collection instead (but this is probably not a great idea) --- for performance in non-SVG cases we could just use className though.

@caitp
Copy link
Contributor

caitp commented Oct 7, 2014

screen shot 2014-10-07 at 6 30 47 pm

mmmyep

@btford
Copy link
Contributor

btford commented Oct 7, 2014

sorry, misspoke. seems like just the visual behavior of setAttribute('class', ...) is broken when elements' attributes use the ng: namespace.

@btford
Copy link
Contributor

btford commented Oct 8, 2014

Because this is such an edge case and the fix would have perf implications, I think we're going to close this as "won't fix"

@btford btford closed this as completed Oct 8, 2014
caitp added a commit to caitp/angular.js that referenced this issue Oct 9, 2014
IE9 has issues with setAttribute() and getAttribute() when an element uses XML namespaces.

This should make the behaviour on IE9 consistent with a minimal perf hit, and make it easy
to remove support when IE9 is no longer supported.

Fixes angular#5001
caitp added a commit to caitp/angular.js that referenced this issue Oct 9, 2014
IE9 has issues with setAttribute() and getAttribute() when an element uses XML namespaces.

This should make the behaviour on IE9 consistent with a minimal perf hit, and make it easy
to remove support when IE9 is no longer supported.

Fixes angular#5001
caitp added a commit to caitp/angular.js that referenced this issue Oct 9, 2014
IE9 has issues with setAttribute() and getAttribute() when an element uses XML namespaces.

This should make the behaviour on IE9 consistent with a minimal perf hit, and make it easy
to remove support when IE9 is no longer supported.

Fixes angular#5001
caitp added a commit to caitp/angular.js that referenced this issue Oct 9, 2014
IE9 has issues with setAttribute() and getAttribute() when an element uses XML namespaces.

This should make the behaviour on IE9 consistent with a minimal perf hit, and make it easy
to remove support when IE9 is no longer supported.

Fixes angular#5001
@caitp
Copy link
Contributor

caitp commented Oct 10, 2014

So, we aren't gonna land the class API fix, too much code, but if you need it, you can monkeypatch with a strategy similar to the one listed there --- you probably don't want to monkeypatch but just patch angular itself, so that ngAnimate can make use of it.

@caitp
Copy link
Contributor

caitp commented Oct 10, 2014

So take a look at https://github.com/angular/angular.js/pull/9510.patch (you can build angular with it with curl https://github.com/angular/angular.js/pull/9510.patch | git am, grunt build) --- if you need this for IE9

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

Successfully merging a pull request may close this issue.

9 participants