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: iframe-window-name-update #11578
base: dev
Are you sure you want to change the base?
fix: iframe-window-name-update #11578
Conversation
…ames window must be updated aswell. Otherwise anchor tags with a 'target' attribute won't hit the right iframe.
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.
Thanks for this and sorry for the late review!
…frame element, the iframes window must be updated as well. Otherwise anchor tags with a 'target' attribute won't hit the right iframe.
// anchor tags with a 'target' attribute won't hit the right iframe. | ||
if (el.tagName === 'IFRAME' && key === 'name' && el.contentWindow) { | ||
// $flow-disable-line | ||
el.contentWindow.name = value; |
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 could be wrong, but AFAICS this could trigger a browser security error, if the iFrame
is cross-origin, e.g. like this:
Uncaught DOMException: Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame.
fix: When changing the attribute 'name' of an iframe element, the iframes window must be updated aswell. Otherwise anchor tags with a 'target' attribute won't hit the right iframe.
Close #11569
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
This Issue actually wasn’t only present in safari. When iframes are created a window will be attached to the iframe which actually is the target. When updating the name attribute of an existing iframe the window inside the iframe doesn’t get updated.
In native javascript you could fix this with:
document.querySelector('iframe').documentWindow.name = 'theNewName';
The reproduction fiddle in the Issue #11569 only is bugged in safari, but if you try to change the attribute dynamically it doesn’t work in chrome or firefox either.
Check this fiddle for the cross-platform issue : https://jsfiddle.net/ug2jhmL6/1/