Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cross origin check for ie #531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tbuechner
Copy link

in ie sometimes the link.protocol and link.hostname attributes are not set correctly, parse the href manually

in ie sometimes the link.protocol and link.hostname attributes are not set correctly, parse the href manually
@mislav
Copy link
Collaborator

mislav commented Jun 1, 2015

Thanks for reporting. If the protocol and hostname aren't properly set, how is re-parsing them using the HTMLAnchorElement going to help set them? Do you have a case in which we can reproduce this?

/cc @mastahyeti

@staabm
Copy link
Contributor

staabm commented Jun 1, 2015

I Can remember that jQuery also uses this "hack" to work around ie limitations, but cannot find the issue/ticket right now.

@tbuechner
Copy link
Author

Unfortunately I cannot provide you with an example. The problem occured on some links in our application, which were dynamically generated. The re-parse then happens on a newly created link, this fixed the issue in our case.

@mislav
Copy link
Collaborator

mislav commented Jun 1, 2015

Without a test case to reproduce it with, I can't merge this yet.

@staabm
Copy link
Contributor

staabm commented Jun 1, 2015

just found the jquery issue/ticket which I was refereing to above:
jquery/jquery#1880

this ticket was about simplifying their URL parsing... they didn't change it because of x-browser issues.
so as @mislav said, as long as we don't have something to reproduce it wouldn't make much sense to land this PR.

@btoews
Copy link

btoews commented Jun 1, 2015

Yep, this sounds rights. IE returns empty hostname and protocol for anchor tags whose href is a relative path, but setting a.href = a.href works around this behavior.

@mislav
Copy link
Collaborator

mislav commented Jun 1, 2015

Oh it's an IE thing? I will check, thanks

@mynock
Copy link

mynock commented Jun 10, 2015

Just experienced this issue (IE only) and the fix in the PR solved it for us. It was happening when loading in content dynamically via AJAX and then changing the href of the new DOM elements. There's probably a simpler repro use case, but that was ours.

@Vovan-VE
Copy link

Reproduced in IE11 for generated link like this:

$('<a/>', {href: '/path/...'})

Debugger shows empty protocol and hostname.

@Vovan-VE
Copy link

IE11

var a = document.createElement('a');
a.href = '/path';

// "", "", "http://host/path"
console.log(a.protocol, a.hostname, a.href);

a.href = a.href;

// "http:", "host", "http://host/path"
console.log(a.protocol, a.hostname, a.href);

@lustremedia
Copy link

+1 I have had this issue with a widget where links are exchanged dynamically. After the href has been exchanged, a click on this link does a full reload of the page under IE11. The changes of this pull request fixes that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants