Skip to content

Fix Facebook embed parsing for legacy XFBML format#761

Merged
GaryJones merged 1 commit into
developfrom
fix/facebook-embed-xfbml-parsing
Dec 19, 2025
Merged

Fix Facebook embed parsing for legacy XFBML format#761
GaryJones merged 1 commit into
developfrom
fix/facebook-embed-xfbml-parsing

Conversation

@GaryJones

Copy link
Copy Markdown
Contributor

Summary

  • Fix Facebook embeds not rendering when cached content uses legacy XFBML format (<fb:post>)
  • The previous check for .fb-post class didn't match XFBML namespace elements
  • Now always calls FB.XFBML.parse(element) when SDK is available, which handles both formats
  • Passes element parameter to scope parsing to current container

Background

Issue #306 reported Facebook embeds not rendering consistently. Investigation revealed that when oEmbed cached content in the legacy XFBML format (<fb:post href="..." data-width="552">), the JavaScript check element.querySelector('.fb-post') would fail because:

  • .fb-post is a CSS class selector
  • <fb:post> is an XML namespace element, not a class

The Facebook SDK's XFBML.parse() function handles both formats, so removing the element check and always calling parse when the SDK is loaded makes the code more robust.

Test plan

  • Added Jest tests for triggerOembedLoad function
  • Tests cover Facebook SDK with both HTML5 and XFBML formats
  • Tests cover Twitter and Instagram SDKs
  • All existing tests pass

Fixes #306

🤖 Generated with Claude Code

The triggerOembedLoad function previously only called FB.XFBML.parse()
when it found elements with the `.fb-post` CSS class. This caused
Facebook embeds using the legacy XFBML format (`<fb:post>`) to not
render, as the CSS selector wouldn't match namespace elements.

Changes:
- Remove the `.fb-post` element check before calling FB.XFBML.parse()
- Always call FB.XFBML.parse(element) when Facebook SDK is available
- Pass element parameter to scope parsing to the current container
- Add comprehensive Jest tests for triggerOembedLoad function

The Facebook SDK's XFBML.parse() handles both modern HTML5 format
(`<div class="fb-post">`) and legacy XFBML format (`<fb:post>`),
so removing the check makes the code more robust for cached embeds
from older liveblog entries.

Fixes #306

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@GaryJones GaryJones requested a review from a team as a code owner December 19, 2025 01:23
@GaryJones GaryJones added this to the 1.10.0 milestone Dec 19, 2025
@GaryJones GaryJones self-assigned this Dec 19, 2025
@GaryJones GaryJones merged commit fa06f36 into develop Dec 19, 2025
10 checks passed
@GaryJones GaryJones deleted the fix/facebook-embed-xfbml-parsing branch December 19, 2025 01:26
@GaryJones GaryJones mentioned this pull request Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Facebook links are stripped in liveblog

1 participant