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

Dynamic html is not able to generated from the embedded script under specific element even after it gets replaced and executed. #364

Closed
yashvekaria opened this issue Nov 26, 2021 · 1 comment

Comments

@yashvekaria
Copy link

Hi,

I am using this parser in the gatsby project, where I get article content in the HTML string format and I sanitize it using the parse method. In my case, I have shown polldaddy (survey) embedded code.

From issue #98, I came to know to execute the script need to use the replace function, which I did for polldaddy, I have replaced the same script using the replace function, which is even getting called in the network (local and staging development) but couldn't able to load render its HTML which gets generated from the replaced script under #pollDaddyInfo div.

I have created a demo in codesandbox

But if I called the same script outside gatsby/react env or in js env then it's working perfectly, Here is jsbin demo

Can you please explain if this issue or rehydration or why this is happening or what approach I should follow to resolve this issue?

@yashvekaria yashvekaria changed the title Dynamic html is not able to generated from the embedded script under specific element even after it gets replaced and execute. Dynamic html is not able to generated from the embedded script under specific element even after it gets replaced and executed. Nov 26, 2021
@yashvekaria
Copy link
Author

I exactly understood the problem lies behind this question, actually, the polldaddy 3rd party script is creating its HTML using document.write() method which creates error as its script is being dynamically added, which does not encourage document.write method. here's is the StackOverflow link

Found this article google article suggesting not use document.write() method for 3rd party scripts

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

1 participant