-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(compile): properly handle false value for boolean attrs with jQuery #16779
Conversation
This touches |
src/ng/compile.js
Outdated
// in XHTML, call `removeAttr` in such cases instead. | ||
// See https://github.com/jquery/jquery/issues/4249 | ||
lowercasedName = lowercase(attrName); | ||
isBooleanAttr = BOOLEAN_ATTR[lowercasedName]; |
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.
Can we not just use booleanKey
here rather than recomputing this stuff?
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.
Using booleanKey
has the difference that it takes the nodeName into account. On the other hand, the current approach stays more similar to jqLite's implementation of attr()
. (Not sure which option is best.)
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.
Using booleanKey
may be a good idea, let me try it.
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.
@petebacondarwin PR updated.
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.
Not sure how I feel about "fixing" this at this point. There will still be a difference between jqLite and jQuery on XML documents (such as XHTML) (e.g. for truthy values or possibly how values are handled for non-BOOLEAN_ELEMENTS).
Will there be a difference for non-XML documents?
(I can't think of any, but am I missing something?)
src/ng/compile.js
Outdated
// in XHTML, call `removeAttr` in such cases instead. | ||
// See https://github.com/jquery/jquery/issues/4249 | ||
lowercasedName = lowercase(attrName); | ||
isBooleanAttr = BOOLEAN_ATTR[lowercasedName]; |
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.
Using booleanKey
has the difference that it takes the nodeName into account. On the other hand, the current approach stays more similar to jqLite's implementation of attr()
. (Not sure which option is best.)
That's true but it's not about
There are some |
832222e
to
504ad88
Compare
false
value for boolean attrs with jQuery504ad88
to
9979ebf
Compare
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.
I am not talking about But maybe that is not a big deal for truthy values. I certainly feel more confident now that In any case, since this will only affect XML-based documents (which shouldn't be that wide-spread any more), I am fine shipping this. |
jQuery skips special boolean attrs treatment in XML nodes for historical reasons and hence AngularJS cannot freely call `.attr(attrName, false) with such attributes. To avoid issues in XHTML, call `removeAttr` in such cases instead. Ref jquery/jquery#4249 Fixes angular#16778
9979ebf
to
fe705a9
Compare
jQuery skips special boolean attrs treatment in XML nodes for historical reasons and hence AngularJS cannot freely call `.attr(attrName, false) with such attributes. To avoid issues in XHTML, call `removeAttr` in such cases instead. Ref jquery/jquery#4249 Fixes #16778 Closes #16779
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
ng-disabled="disabled"
always disables the element in XHTML mode when jQuery is used, even when thedisabled
binding is set tofalse
.What is the new behavior (if this is a feature change)?
Yes, but only in XML mode (a.k.a. XHTML).
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Fix/Feature: Docs have been added/updatedN/AOther information:
jQuery skips special boolean attrs treatment in XML nodes for historical reasons
and hence AngularJS cannot freely call
.attr(attrName, false) with such attributes. To avoid issues in XHTML, call
removeAttr` in such cases instead.Ref jquery/jquery#4249
Fixes #16778