Remove browser sniff in urlUtils.js #15612
Description
Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug?
Neither. Potential bug.
What is the current behavior?
Depends on browser and configuration. May "work" by coincidence in currently supported browsers, but could break in future.
This would be trivially easy to feature test and then would work in any browser that demonstrates the defect. Furthermore, will stop doing the extra work if the bug is ever fixed in IE.
Also note that not all MSHTML-based environments are IE.
// Support: IE 9-11 only
if (msie) {
// Normalize before parse. Refer Implementation Notes on why this is
// done in two steps on IE.
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
The steps to test it are spelled out in the implementation notes.
- Set the attribute on the dummy link to a value lacking a protocol, host, etc.
- Check to see if protocol, host, etc. properties are empty strings.
urlParsingNode.setAttribute('href', 'foo');
var problemSettingHrefAttribute = urlParsingNode.host === '';
Do that once during initialization and then make a direct inference based on the result:
if (problemSettingHrefAttribute) {
// Normalize before parse. Refer Implementation Notes on why this is
// done in two steps.
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}