heiseonline / embetty

🐙 Embetty displays remote content like tweets or YouTube videos without compromising your privacy.
MIT License
989 stars 32 forks source link

Breaks Promises from unrelated JavaScript code #36

Closed bingeling closed 3 years ago

bingeling commented 6 years ago

General information

Steps to reproduce the behaviour

Create a build of embetty and add it to a web project (in this case a Ruby on Rails project, but should be irrelevant) that is running unrelated JavaScript code which makes use of Promises.

Expected behaviour

Embetty should stay in its lane. No error should occur.

Actual behaviour

Embetty tries to resolve Promises from unrelated parts of the codebase, then throws an error because it doesn't know what to do with the result of the Promise. Happens only in browsers listed above.

One example from our image lazy loading logic is:

SyntaxError: '[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement],[object HTMLImageElement]' is not a valid selector

As far as we have been able to debug this issue, this is caused by the shadydom code that is bundled with embetty as part of the webcomponents polyfill. And so this issue only occurs in browsers that don't natively support Shadow DOM.

We can't determine why it would do that or how it does that. We can't even determine which part of the code does it, since all embetty dependencies are transpiled/minified, even when we debugged the issue with a not-transpiled/not-minified test-build of embetty. We just saw that the error occurred in the webcomponent polyfill part of the code.

mick352 commented 5 years ago

Hi,

thanks for reporting this. Could you please try to reproduce this with the latest version? And add some code/test case to show how to trigger it? Please forgive us for taking this long to respond.

bingeling commented 4 years ago

I have since switched jobs and no longer have access to the code base. I'll pass it on to the company, but can't promise that they'll get back to you.

mick352 commented 4 years ago

Thanks for the update @bingeling !