• Resolved darknessfx

    (@darknessfx)


    Problem:
    If you set Capture consent & hide the banner to 30 seconds, if the user already had the cookie the script throw an error.

    Error:
    Uncaught TypeError: Cannot read property ‘removeChild’ of null
    at eu-cookie-law.min.js?ver=20180522:2

    Script:
    function(){n.parentNode.removeChild(n);…

    Solution?
    Needs to check if the element exists on the webpage before try to removeChild.

    • This topic was modified 4 years, 8 months ago by darknessfx.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter darknessfx

    (@darknessfx)

    Solved:
    Edit /wp-content/plugins/jetpack/_inc/build/widgets/eu-cookie-law/eu-cookie-law.min.js
    Column 1391
    Replace:
    n.parentNode.removeChild(n)
    With:
    try {n.parentNode.removeChild(n)} catch (error) {}

    Plugin Support KokkieH

    (@kokkieh)

    Hi there,

    Can you please expand a bit on the steps to replicate this issue? I don’t understand exactly what you described above.

    Alternatively, as you’ve already figured out how to fix it, do you want to open an issue and submit a pull request for this on GitHub directly?

    https://github.com/automattic/jetpack

    Thread Starter darknessfx

    (@darknessfx)

    Hi there,

    How to replicate:
    Open WordPress Admin Dashboard.
    Go to Appearance > Widgets.
    Add Cookies & Consents Banner (Jetpack) to your primary sidebar.
    Set Capture consent & hide the banner to After this amount of time 30 seconds.
    Save.
    Visit your WP page (maybe using an European VPN?).
    The Cookies and Consent banner shows up, click Agree.
    Open your browser DevTool, check Console outputs. No errors.
    Press F5 (Refresh).
    The widget knows you already consent, so it don’t display the banner again. But.
    After 30 seconds, the timer script is still active to destroy/remove the banner even if the script never created the banner this time, it fails to find the banner (n.parentNode = null) and throws this error (Cannot read property ‘removeChild’ of null).

    I can open the issue ans commit suggestion on github, no problems.

    Plugin Support fresatomica

    (@fresatomica)

    I can open the issue ans commit suggestion on github, no problems.

    That would be great, our developers would be able to check this directly.

    https://github.com/Automattic/jetpack/issues

    Feel free to link the issue you create in the reply. Thanks!

    Thread Starter darknessfx

    (@darknessfx)

    Plugin Support fresatomica

    (@fresatomica)

    Awesome, thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘EU Cookie Law – Script error’ is closed to new replies.