Skip to content

fix: use Blob URL for JSON export instead of DOM appendChild pattern - #589

Merged
gopaljilab merged 3 commits into
gopaljilab:mainfrom
nyxsky404:fix/export-json-blob-pattern
Jun 2, 2026
Merged

gopaljilab merged 3 commits into
gopaljilab:mainfrom
nyxsky404:fix/export-json-blob-pattern

Conversation

@nyxsky404

@nyxsky404 nyxsky404 commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replaces the exportToJson function's outdated document.body.appendChild + data: URI pattern with a modern Blob + URL.createObjectURL approach. The old pattern could leak DOM elements if click() threw, and data: URIs have browser URL length limits for large exports.

Related Issue

Fixes #582

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style / UI improvement
  • ♻️ Refactor (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update
  • 🔧 Chore / Tooling / Config

Changes Made

  • Replaced data: URI encoding with new Blob([...], { type: "application/json" })
  • Used URL.createObjectURL for the download link
  • Called URL.revokeObjectURL after download to free memory
  • Removed document.body.appendChild / .remove() — no longer needed

Testing

  • I have tested these changes locally
  • All existing tests pass

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • I have updated the documentation if needed

@gopaljilab
gopaljilab merged commit 7ae4dae into gopaljilab:main Jun 2, 2026
3 of 7 checks passed
@github-actions github-actions Bot added gssoc:approved level:intermediate Requires standard familiarity with the codebase. type:bug Something isn't working or throwing errors. labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved level:intermediate Requires standard familiarity with the codebase. type:bug Something isn't working or throwing errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] exportToJson uses outdated DOM pattern and can leak anchor elements

2 participants