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: iframe-window-name-update #11578

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

christoph-schaeffer
Copy link

@christoph-schaeffer christoph-schaeffer commented Aug 8, 2020

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)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

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/

…ames window must be updated aswell. Otherwise anchor tags with a 'target' attribute won't hit the right iframe.
Copy link
Member

@posva posva left a 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!

src/platforms/web/runtime/modules/attrs.js Outdated Show resolved Hide resolved
@posva posva added this to In Review in 2.6.13 Mar 24, 2021
…frame element, the iframes window must be updated as well. Otherwise anchor tags with a 'target' attribute won't hit the right iframe.
@posva posva changed the title fix: iframe-window-name-update (fixes Issue #11569) fix: iframe-window-name-update Mar 30, 2021
@posva posva added this to Planned in 2.6.15 via automation Jun 1, 2021
@posva posva moved this from Planned to In Review in 2.6.15 Jun 1, 2021
// 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;
Copy link

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.

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

Successfully merging this pull request may close these issues.

Safari doesn't see frame inside vue app
3 participants