-
Notifications
You must be signed in to change notification settings - Fork 27.4k
nodeName_ does not properly canonicalize element names when using XHTML #3987
Comments
This was causing SCE to throw an error on an interpolated value in |
Here is some background info: http://ejohn.org/blog/nodename-case-sensitivity/ |
The concern I have is one of performance. It seems that wasteful to be running |
Another possible option would be to define variables IMG, OPTION, etc. which are set either to "IMG" or "img" depending on the document/browser type. Checks like |
@yuri0 - that solution wouldn't really scale so well as new elements are defined? |
What does jQuery do? |
This doesn't look good: http://jsperf.com/jquery-is-vs-node-name-tolowercase |
Actually, Interestingly, this last case is the only one that is not doing a direct comparison to a constant string. And in this case it is called |
@petebacondarwin by my count, these types of checks are done in only 9 places throughout the code, and only on HTML, PRE, IMG, SELECT, TITLE. |
and A |
I think nodeName_ should be changed to return lowercase: https://developer.mozilla.org/en-US/docs/Writing_JavaScript_for_XHTML#Problem.3A_Names_in_XHTML_and_HTML_are_represented_in_different_cases |
Then we wouldn't need to call lowercase() when normalizing directive names and just simple check against lowercase constants. But I am still unsure of the performance impact. Some of this code is very "hot" |
This line: https://github.com/angular/angular.js/blob/master/src/jqLite.js#L502 could be changed to:
which would be faster than it is now for the majority of cases. |
These lines: https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L366-L370 could be changed to:
|
This line https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L619 is made simpler:
|
Lines https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1284 and https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1298 would simple change to
and
|
There are a few places that also use |
@yuri0 - fancy putting a PR together? |
Sorry for taking so long (mainly, not making the 1.2 release), I'd never done a PR before and then forgot about it. |
XHTML uses lowercase node names, while HTML often uses uppercase. The generally accepted convention is to always lowercase them. Fixes angular#3987
XHTML uses lowercase node names, while HTML often uses uppercase. The generally accepted convention is to always lowercase them. Fixes angular#3987
XHTML uses lowercase node names, while HTML often uses uppercase. The generally accepted convention is to always lowercase them. Fixes angular#3987
Angular code assumes that element names will be uppercase. I am using Angular with XHTML5 (with
application/xhtml+xml
MIME type), where this is not the case. The code in question is the following:I was able to remedy this in my situation by simply wrapping the return value of the
else
block in a call touppercase()
; however, before committing this as a fix I'd like some insight from someone who knows the internals better than me.Specifically, I'm not sure if/how the
msie < 9
block should be changed. I'm guessing the return value should be wrapped again, but doeselement.scopeName
also need to be canonicalized? Is this a moot point since IE doesn't support XHTML anyway?The text was updated successfully, but these errors were encountered: