Skip to content

feat(file): add webkitRelativePath property to File class#2119

Open
spaciousejar wants to merge 2 commits intocapricorn86:masterfrom
spaciousejar:fix/add-webkit-relative-path
Open

feat(file): add webkitRelativePath property to File class#2119
spaciousejar wants to merge 2 commits intocapricorn86:masterfrom
spaciousejar:fix/add-webkit-relative-path

Conversation

@spaciousejar
Copy link
Copy Markdown

Summary

Adds the missing webkitRelativePath property to the File class as required by the W3C File API specification.

Problem

The File class in Happy-DOM was missing the webkitRelativePath property, which should be present and default to an empty string according to the W3C File API specification.

This property is commonly used when working with file uploads, particularly when handling directory uploads where browsers need to preserve relative paths within the directory structure.

Solution

  • Added readonly webkitRelativePath: string = '' property to the File class
  • Added a test case to verify the property returns an empty string by default
  • Follows the W3C specification requirement that this property should default to an empty string

Changes

  • File.ts: Added the webkitRelativePath property with empty string default
  • File.test.ts: Added test case to verify correct default behavior

Testing

  • Added unit test that verifies webkitRelativePath returns an empty string by default
  • The fix is minimal and follows the exact specification requirements

W3C Specification Reference

According to the W3C File API specification:

The webkitRelativePath attribute must return the value it was initialized to. Initially, this is the empty string.

Fixes #2093

Adds the missing webkitRelativePath property to the File class as per W3C File API specification. The property defaults to an empty string as required by the spec.

- Add readonly webkitRelativePath property with empty string default
- Add test case to verify the property returns empty string by default

Fixes capricorn86#2093
Copilot AI review requested due to automatic review settings April 1, 2026 00:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the missing webkitRelativePath property to Happy-DOM’s File implementation to align with the W3C File API behavior (defaulting to an empty string), and verifies it via a unit test.

Changes:

  • Added readonly webkitRelativePath: string = '' to File.
  • Added a unit test asserting webkitRelativePath defaults to ''.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/happy-dom/src/file/File.ts Adds the webkitRelativePath property with an empty-string default on File instances.
packages/happy-dom/test/file/File.test.ts Adds coverage to ensure webkitRelativePath returns '' by default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

File is missing webkitRelativePath

2 participants