orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
3.91k stars 407 forks source link

[Feat]: Parse again function for dynamic Html component #590

Closed gitVasile closed 10 months ago

gitVasile commented 11 months ago

Description

If I add the piece of code below in my DOM dynamically, the cookieconsent will never be able to parse this new code because it was added after the loaded.

<script type="text/plain" data-cookiecategory="optional" lang="js">alert('ok')</script>

Proposed solution

We should maybe add a way to parse the code again using a mehtod from you api.

Additional details

Thank you

orestbida commented 11 months ago

@gitVasile, you can use the .updateScripts() method to let the plugin know of the newly added script tags.

gitVasile commented 11 months ago

Hey @orestbida ok, but why about iframe newly added for example? Is updateScripts() parsing all the elements?

Thank you

orestbida commented 11 months ago

Unfortunately no, the plugin only handles scripts.

gitVasile commented 10 months ago

Ok, no problem. Thank you for your time and project 👍 .

orestbida commented 10 months ago

@gitVasile I forgot to mention as I was in a hurry, but there's a dedicated plugin to handle iframes, called iframemanager, although it too does not handle dynamically injected iframes.

gitVasile commented 10 months ago

Hey @orestbida Thank you for your help. Should be fine.

Have a nice day