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

perf(ngOptions): avoid calls to element.value #15344

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/directive/ngOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
element.label = option.label;
element.textContent = option.label;
}
if (option.value !== element.value) element.value = option.selectValue;
element.value = option.selectValue;
Copy link
Member

Choose a reason for hiding this comment

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

Interestingly, option.value will always be undefined, so this was a redundant.
I wonder what the intenton was, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gkalpak I noticed the same thing. That's how I new this check would be safe to remove. My guess is it was intended to be option.selectValue !== element.value and the thought was that would prevent setting element.value if it didn't need to be. Strange thing about that though is that this function is only ever called from the addOptionElement function and it creates a new element cloned from optionTemplate everytime . So, I don't think element.value will ever actually have a value prior to this line anyway. Makes me wonder if the check a few lines above option.label !== element.label is necessary.

}

function updateOptions() {
Expand Down