Skip to content

fix: Handle empty alt for images in implied p-name #413

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

Merged
merged 3 commits into from
Jun 27, 2025

Conversation

benjifs
Copy link
Contributor

@benjifs benjifs commented Jun 20, 2025

Fixes #400

Checklist

  • Added validaton to any changes in the parser API.
  • Added tests covering the parsing behaviour changes.
  • Linked to any relevant issues this will close.
  • Tested the output using the demo.

Empty alt text (<img alt="" .../>) is used for implied name properties but the spec specifically mentions not using an empty value.

Also changed the behavior to use impliedTextContent instead of textContent when parsing p-* otherwise it adds the images src when parsing.

Example input covered by new behaviour

<a class="p-author h-card u-url" href="/">
  Author
  <img class="u-photo" src="/photo.jpg" alt="" />
</a>

Example output from new behaviour

{
  "items": [
    {
      "type": ["h-card"],
      "properties": {
        "photo": ["http://example.com/photo.jpg"],
        "name": ["Author"]
      }
    }
  ]
}
@aimee-gm aimee-gm self-assigned this Jun 27, 2025
@aimee-gm aimee-gm merged commit 1e4a025 into microformats:main Jun 27, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants