-
Notifications
You must be signed in to change notification settings - Fork 385
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
support Element.classList.add and Element.classList.remove #5913
Comments
|
This should be fully supported. DOMTokenLists are supported, and classList is one of them. Can you provide a reproduction where it's not working? |
@slapbox @kristoferbaxter The Footnotes plugin for WordPress has a hard links enabled mode since last year for AMP compatibilty, and alternative tooltips as well as an alternative reference container, both using plain JavaScript. The tooltips use this internal script:
You see that the only functions used are classList.add() and classList.remove(). In spite of this simplicity and light-weight, the AMP plugin removes this script, (It also removes most of the CSS; the only remainder I can spot is To reproduce the issue, please install the plugin and set it to Enable alternative tooltips, and Script mode plain JavaScript. Enable hard links is automatic when Script mode is plain JavaScript. In this configuration, no libraries are loaded (neither jQuery Core, nor jQuery UI, all from WordPress, nor jQuery Tools shipped with the plugin). Looking at the page source I don’t see the |
Transferred this issue to |
Hello @pewgeuges AMP pages do not allow custom javascript on AMP pages, so the AMP plugins remove them for you to produces valid AMP pages. You can however use amp-script component to use javascript on AMP pages with few restrictions In your case I don't see why we need javascript to toggle footnote, this can be also achieved using a simple CSS tweak. goto -> Dashboard-> Appearance -> Customize -> Addtional CSS -> paste bewow CSS html[amp] span.footnote_referrer:hover > span.footnote_tooltip {
visibility:visible;
opacity:1;
} let me know if this resolves your issue |
This is fabulous! Thanks a lot! No need for JS to display fully fledged tooltips! The only change needed was remove the root element and its attribute selector, as even when using an argument present it failed. The now working is: span.footnote_referrer:hover > span.footnote_tooltip {
visibility:visible;
opacity:1;
}
|
Solved also with asymmetric transitions. The rules are now: span.footnote_referrer > span.footnote_tooltip {
visibility: hidden;
opacity: 0;
transition-property: visibility, opacity;
transition-delay: 500ms;
transition-duration: 1s;
}
span.footnote_referrer:hover > span.footnote_tooltip {
visibility: visible;
opacity: 1;
transition-property: visibility, opacity;
transition-delay: 0;
transition-duration: 200ms;
} We’ll change the internal CSS accordingly (where values come in from settings). Thank you very much for helping make the plugin AMP compatible! |
Just a last thing @milindmore22: We acknowledge everyone contributing code or reporting issues. May we list you among the contributors, credit you in the changelog, and link the issue in a docblock or two? (Having hyperlinks in the changelog is also on the table.) (Our issue #41 is to complete the doc thoroughly.) |
Once you've released the AMP-compatible version on WordPress.org, please let us know and we'll test and then add to our AMP-compatible plugin ecosystem directory: https://amp-wp.org/ecosystem/plugins/ |
@pewgeuges Also, in regards to |
Yes, it will be a pleasure, Thank you @westonruter! |
@westonruter Thanks a lot! I’ll dig into these pseudo-classes. FWIW with jQuery tooltips I can tap-and-hold a referrer, then the tooltip shows up on mobile. Hopefully :focus or :focus-within will perform the same — w/o JS! |
Makes me so happy to see such a great outcome. Thanks all! |
@pewgeuges Glad to know the solution helped, feel free to reach us on WordPress Support Forums and we will more than happy to assist you further. |
The lean implementation of styled tooltips requires to add and remove classes for the shown and hidden status.
The text was updated successfully, but these errors were encountered: