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

Broken in Safari with an iframe #109

Closed
ayush opened this issue Jun 21, 2015 · 7 comments
Closed

Broken in Safari with an iframe #109

ayush opened this issue Jun 21, 2015 · 7 comments

Comments

@ayush
Copy link

ayush commented Jun 21, 2015

Thanks much for Readmore.js! It works great but we noticed a problem. If there is an iframe inside a div, then Readmore.js does not display the contents of iframe on Safari. On other browsers (Chrome/Firefox) it works fine. On OSX or iOS Safari the iframe contents are not rendered.

Any idea what might be causing this behavior?

Plunker which shows the problem

I have a plunker which demonstrates this problem: http://plnkr.co/edit/SCr7jmwmxQYrsTfDvsIY?p=preview

On Safari you see:

screen shot 2015-06-21 at 10 50 11 am

On Chrome/Firefox you see:

screen shot 2015-06-21 at 10 49 54 am

@jedfoster
Copy link
Owner

Not a Readmore.js issue.

@ayush
Copy link
Author

ayush commented Sep 1, 2015

Hi @jedfoster why isn't this a Readmore.js issue? My plunker clearly gives you a sandbox to reproduce it.

@ayush
Copy link
Author

ayush commented Oct 3, 2015

Hi @jedfoster I'd appreciate if you could give some more details about why you think this isn't a Readmore.js issue. I'd carefully created a plunker so that you'd be able to reproduce the problem.

@krisdigital
Copy link

krisdigital commented Jun 9, 2016

Had the same problem, it has something to do with the script cloning dom elements as far as I can see. Wrote a tiny script that is enough for my readmore needs, is very small and is tuned for performance.

https://github.com/krisdigital/readmore-light-js

@jedfoster
Copy link
Owner

@krisdigital I'm curious if your issue is exactly the same as @ayush's? Do you have a page that shows the issue?

(BTW, I love that you linked to sassmeister.com!)

@jedfoster
Copy link
Owner

FWIW, I found that resetting the iframe's source at the end of setBoxHeights ""fixes"" the issue. See: http://plnkr.co/edit/tT30vAOyaHr40sHrafBL?p=preview

I say ""fixes"" because it feels hacky.

The ""fix"" is:

  function setBoxHeights(element) {
    //...

    element.find('iframe').each(function() {this.src = this.src;});
  }

Removing the cloned node seems to unload the iframe; calling hide() instead of remove() on line 86 also ""fixes"" the issue (can't leave those cloned nodes laying around.)

I still don't think this is an issue with anything in Readmore.js, it is a Safari issue. Admittedly, cloning, sizing, removing, and then resizing nodes is not a common operation (or at least, it shouldn't be :-), but I believe this to be a rare corner-case issue with this one browser.

Readmore.js was intended to work with text, not arbitrary HTML blocks. I am disinclined to include this ""fix"" in Readmore.js at this time.

@krisdigital
Copy link

Hi @jedfoster,

I did not know that sassmeister.com is your site! LOL, you are everywhere!

Yes I am pretty sure I had the same issue as @ayush and it was only in Safari and not always, but most of the time.

I just posted my solution as it might help others with the same problem. It is a different approach and it works well in my case.

I do not have a page with the issue online anymore..

Cheers!

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

No branches or pull requests

3 participants