Binding to the src of an iframe causes the iframe to flicker
See original GitHub issueBinding to the src
property of an iframe causes the iframe to reload every time change detection is run, even when the src
value has not changed.
Reproduction: https://plnkr.co/edit/CgLHkprl4jYndqEiY7mX?p=preview
(enter X1RVYt2QKQE
as an example videoId, then type into the unrelated input)
Happens with all Angular versions <= 4.1 (current version at time of this writing)
Note from @tbosch:
So the problem is that
this.domSanitizer.bypassSecurityTrustResourceUrl
returns a new object every time it is invoked. If the result is cached, the flickering is gone, see https://plnkr.co/edit/W0gJKmRsGUpzb1QNZqf5?p=previewEventually, we could change our behavior in that
bypassSecurityTrustResourceUrl
would use an internal cache already.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:10
Top Results From Across the Web
How to set <iframe src="..."> without causing `unsafe value ...
Error: unsafe value used in a resource URL context at DomSanitizationServiceImpl.sanitize... I have already tried using bindings with [src] with ...
Read more >The ultimate guide to iframes - LogRocket Blog
Not a fan of iframes? This post provides an overview of the tag's best features, shows you how to use them, and how...
Read more >Prevent White Flash While Iframe Loads - CSS-Tricks
It inserts some CSS on the page (right away) which makes all iframes invisible. You can't see a white flash on an iframe...
Read more >chrome iframe flicker - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >iFrame Resizer - GitHub Pages
The most likely cause of this problem is having set the height of an element to be 100% of the page somewhere in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@anupvarma @danieltorrer I have found a solution, you just have to put the email modifying the dom by your own. I attach a code sample below
component.html
<iframe src="" frameborder="0" height="700" ></iframe>
component.ts
Thanks @juanbenitopr For me the solution was to save the safeUrl and use it on
[src]
but setting it directly to the dom seems also like a great solution<iframe [src]="video.safeURL" frameborder="0" height="700" ></iframe>