• Resolved web1media

    (@web1media)


    hello, since the last an error with the accordion.js script appears and force to delete the latter in the AMP console. Any idea how to correct the problem? Thank you in advance and have a good evening

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

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Marc Tönsing

    (@marcdk)

    Hi,

    i need an image or the error text. Does it say something about “invalid attributes” and “role navigation” or ARIA? Because that is was changed in the last update. And is this fixed if you install the previous version?

    Previous version: https://downloads.wordpress.org/plugin/simpletoc.5.0.55.zip

    • This reply was modified 1 year, 11 months ago by Marc Tönsing.
    Thread Starter web1media

    (@web1media)

    Thank you for your reply.
    Here is the picture:
    <a href=”https://www.petit-fichier.fr/2023/03/15/screenshot-2023-03-15-194233/ “>https://www.petit-fichier.fr/2023/03/15/screenshot-2023-03-15-194233/
    I “solved” the problem by removing the “Hide in accordion menu” function
    In answer to your question, I am testing with the previous version.

    Thread Starter web1media

    (@web1media)

    Even in the previous version, it’s the “accordion menu” function that poses a problem: by deactivating it, no more problems, too bad I really liked this function.

    Plugin Author Marc Tönsing

    (@marcdk)

    Well the script is really simple and did ever change. In need to know what makes it suddenly “invalid”.

    Thread Starter web1media

    (@web1media)

    We too would like to know but the facts are there, as simple as described: with accordion, AMP error, without, everything is fine.

    Plugin Author Marc Tönsing

    (@marcdk)

    I understand. But I need to know what is exactly the problem. The according.js is this short:

    https://github.com/mtoensing/simpletoc/blob/master/src/accordion.js

    const coll = document.getElementsByClassName( 'simpletoc-collapsible' );
    
    for ( let i = 0; i < coll.length; i++ ) {
    coll[ i ].addEventListener( 'click', function () {
    this.classList.toggle( 'active' );
    const content = this.nextElementSibling;
    if ( content.style.display === 'block' ) {
    content.style.display = 'none';
    } else {
    content.style.display = 'block';
    }
    } );
    }

    And it was like this from the beginning. Maybe this is a false positive? But to help to figure this out please try to point me to the exact line that makes this invalid for AMP in that specific AMP plugin.

    And ChatGPT tells me:
    “Without more information on the specific error message that the plugin is providing, it is difficult to pinpoint exactly why this code is being flagged.”

    Thread Starter web1media

    (@web1media)

    Here is the additional information from the error validation interface, is that better for you?

    https://www.petit-fichier.fr/2023/03/16/screenshot-2023-03-16-104445/

    État
    Retiré (Unreviewed)
    Information
    AMP does not allow the use of JS <script> tags unless they are for loading AMP components, which are added automatically by the AMP plugin. For any page to be served as AMP, all invalid script tags must be removed from the page. Instead of custom or third-party JS, please consider using AMP components and functionality such as amp-bind and actions and events (as opposed to JS event handler attributes like onclick). Some custom JS can be added if encapsulated in the amp-script. Learn more about how AMP works.

    If all invalid markup is “removed” the page will be served as AMP. However, the impact that the removal has on the page must be assessed to determine if the result is acceptable. If any invalid markup is “kept” then the page will not be served as AMP.

    Code d’erreurDISALLOWED_TAG

    Balisage non valide

    <script … >Attributs de l’élément

    Nom de l’élément

    src : https://…website…/wp-content/plugins/simpletoc/src/accordion.jsidsimpletoc-accordion-js

    script

    Élément parentbody

    Plugin Author Marc Tönsing

    (@marcdk)

    Since the script did not change in the last few months, maybe you installed a plugin that “optimizes” html for speed and adds script tags. Because SimpleTOC does not use a script tag. It enqueues the script and leaves how to do it to WordPress.

    Thread Starter web1media

    (@web1media)

    Thank you for your contribution. I see with our administrator and keep you informed if necessary. Good day

    Thread Starter web1media

    (@web1media)

    For information, even by disabling the compression extension, the error still appears: we have abandoned the accordion function to be able to continue to use the summary with AMP

    Plugin Author Marc Tönsing

    (@marcdk)

    Did you clear the cache? It would still be interesting why this happens and what the problem is. Which AMP plugin did you use? Did you contact thw author of the AMP Plugin?

    Plugin Author Marc Tönsing

    (@marcdk)

    Closed. the js is valid

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘AMP Script non valide: accordion.js’ is closed to new replies.