-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(jqLite): Chrome specific issue for <select required>
#7136
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
how was this related to a performance regression? |
@caitp You are right, I try to use the template and thought that "performance/regression" was a performance issue or a regression. Just fixed it |
I do not like this patch, just too hacky. Will close it until I find a better solution |
The patch at 9c66807 is a lot better than the previous patch (and it fixes the issue at the right location) |
+1 to this patch. Works for resolving #7202 which causes workaround on #638 (comment) to break. Edit: I take that back. This patch doesn't work for me. I was testing on the wrong version of AngularJS when I reported that it works.
|
I used: if (element[0].hasAttribute('selected')) {
element[0].selected = true;
}
|
@lgalfaso , please consider using |
@mzgol can you please comment on #7136 (comment) ? |
@@ -171,6 +171,9 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { | |||
$element.val(value); | |||
if (unknownOption.parent()) unknownOption.remove(); | |||
} | |||
if (element.attr('selected') === 'selected') { |
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.
hasAttribute('selected')
is likely safer
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.
@IgorMinar there is no hasAttribute
at the jqLite level, two options, do
element[0].hasAttribute && element[0].hasAttribute('selected')
or
isDefined(element.attr('selected'))
Which alternative you think it 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.
element[0].hasAttribute('selected')
is fine
lgtm |
TBH I'd rather just say we support jQuery >= 1.8 and that we don't support jQuery Migrate than try to bypass the method made for what we're trying to do here just because older jQuery versions had broken semantics with respect to treating |
@lgalfaso I think that @mzgol is right. unless the version of jQuery are testing against is affected by this, we should just use jQuery apis. Also can you please add a comment that this is to work around https://code.google.com/p/chromium/issues/detail?id=381459 into the code? Can you merge this in? |
Take note that jQuery >= 1.9 with jQuery Migrate won't work if you use the jQuery APIs (as I mentioned above). jQuery Migrate helps users migrate from pre-1.9 to jQuery >= 1.9, so if users add jQuery Migrate to upgrade to jQuery >= 1.8 to upgrade to say jQuery 2.0, the API will be broken (for this PR). If you do use jQuery APIs for this PR, users that are now dependent on jQuery < 1.8 or jQuery Migrate (jQuery >= 1.9) are now restricted to jQuery >= 1.8 && jQuery < 1.9 . That is unless they rewrite their application to fix all the breaking jQuery API changes in jQuery 1.9 so they can avoid using jQuery Migrate. |
We currently don't test against the migrate plugin and I'm quite sure that
|
When adding a new <option> element, if the DOM of this option element states that the element is marked as `selected`, then select the new <option> element Closes angular#6828
The migrate plugin is forward compatible, and the use of the |
Conflicts: src/ng/directive/select.js
If that's the case the we can perform the attribute check via the raw DOM On Tue, Jul 8, 2014, 10:14 AM Chris Chua notifications@github.com wrote:
|
I understand that doubt since you're not testing against the migrate plugin. I'm just trying to drive at the point that I feel there are a number of people dependent on jQuery Migrate when upgrading jQuery and this seems trivial enough to pick the safer option. |
fix(jqLite): Chrome specific issue for `<select required>`
Request Type: bug, regression
How to reproduce: Look at #6828
Component(s): jqLite
Impact: medium
Complexity: small
This issue is related to: regression
Detailed Description:
When using Chrome and adding a
<option selected="selected">
to a<select required>
then the new added option is not selectedOther Comments: