AMP Script non valide: accordion.js
-
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]
-
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.
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.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.
Well the script is really simple and did ever change. In need to know what makes it suddenly “invalid”.
We too would like to know but the facts are there, as simple as described: with accordion, AMP error, without, everything is fine.
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.”-
This reply was modified 1 year, 11 months ago by
Marc Tönsing.
-
This reply was modified 1 year, 11 months ago by
Marc Tönsing.
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 likeonclick
). 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’erreur
DISALLOWED_TAG
Balisage non valide
<script … >
Attributs de l’élémentNom de l’élément
src : https://…website…/wp-content/plugins/simpletoc/src/accordion.jsidsimpletoc-accordion-js
script
Élément parent
body
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.
Thank you for your contribution. I see with our administrator and keep you informed if necessary. Good day
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
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?
Closed. the js is valid
-
This reply was modified 1 year, 11 months ago by
- The topic ‘AMP Script non valide: accordion.js’ is closed to new replies.