[wp-meta] [Making WordPress.org] #7877: Share on Mastodon icon doesn't work
Making WordPress.org
noreply at wordpress.org
Tue Jan 7 01:26:22 UTC 2025
#7877: Share on Mastodon icon doesn't work
--------------------------------------+---------------------
Reporter: sebastienserre | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: Make (Get Involved) / P2 | Resolution:
Keywords: needs-patch 2nd-opinion |
--------------------------------------+---------------------
Comment (by dd32):
@jeherve Thanks for that!
That code is running on page load, but o2 re-renders the content after the
code has run.
There's code included in the sharing JS to catch when a new post is added,
but it seems like it was changed to target the infinite-scroll event only,
rather than the one that O2 uses.
This seems to have happened in
https://github.com/Automattic/jetpack/commit/29cf4c78b25d6845085038e3a05139dc2c5ab829
The o2 one isn't namespaced as you can see in
https://github.com/search?q=repo%3AAutomattic%2Fo2%20post-load&type=code
However, Since the jQuery events (used by o2) are "on top of" the DOM and
are not DOM native events, I suspect we actually have to fix this in o2
rather than JP.. which is kinda annoying, because it'll mean either a)
Switching everything from jQuery events to native events, or b) Firing
both types of events.
Regardless; SD probably would want to also listen to the generic `post-
load` event rather than just the `is.post-load` which I've assumed is
infinite-scroll.
To confirm this, the below JS causes this to be fixed, by listening for
the o2 jQuery event and firing the native custom event that SD is
listening for.
{{{
add_action( 'wp_footer', function() {
echo "<script>
jQuery( 'body' ).on( 'post-load', function() {
var e = document.createEvent( 'CustomEvent' );
e.initCustomEvent( 'is.post-load', true, true,
null );
document.body.dispatchEvent( e );
} );
</script>";
} );
}}}
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/7877#comment:2>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list