Blob and File serialization steps drop the type attribute (all engines keep it; WPT asserts it)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- html, javascript
- Lĩnh vực
- web-dev
Hướng nghiên cứu
Read the Blob and File serialization and deserialization sections in the File API specification, then inspect WPT's compare_Blob in html/webappapis/structured-clone/structured-clone-battery-of-tests.js. Update the four algorithms to preserve type and verify the structured-clone, postMessage, and IndexedDB cases pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The serialization and deserialization steps for Blob and File don't carry the type attribute, but every engine keeps it and WPT asserts it.
What the spec says
Blob's serialization steps set serialized.[[SnapshotState]] and serialized.[[ByteSequence]], and the deserialization steps restore only those two. File's steps add [[Name]] and [[LastModified]]. None of the four algorithms mentions type, so read literally:
structuredClone(new Blob(["x"], { type: "text/plain" })).type // "" by the spec text
structuredClone(new File(["x"], "a.txt", { type: "text/plain" })).type // "" by the spec text
The same holds for postMessage, history.pushState, and IndexedDB's StructuredSerializeForStorage.
What engines do
All three keep the type ("text/plain" above):
- Blink:
V8ScriptValueSerializer::WriteDOMObjectwrites the blob's uuid, type and size (kBlobTag), and File's type with its other fields. - WebKit:
SerializedScriptValue.cpp:CloneSerializerwritesblob->type()after the URL (BlobTag) andfile.type()(FileTag), andreadFilepasses the type toFile::deserialize. - Gecko:
StructuredCloneHolder.cpp:WriteBlobkeeps a reference to theBlobImpl(which holds the content type), andReadBlobwraps the same impl, so the type carries over.
Tests
WPT's compare_Blob (html/webappapis/structured-clone/structured-clone-battery-of-tests.js) asserts actual.type === input.type for every cloned Blob and File, across the structured-clone, postMessage and IndexedDB variants.
Proposal
- Blob serialization steps: add "Set
serialized.[[Type]]to the value ofvalue'stypeattribute." - Blob deserialization steps: add "Initialize the value of
value'stypeattribute toserialized.[[Type]]." - File serialization and deserialization steps: the same two steps.
Possibly related: #98 (whether a clone copies or references the data), which doesn't cover type.
Found while implementing structured serialization for Blob and File in Crane, a web platform engine, which keeps the type as the engines do.
- Ngôn ngữ chính
- HTML
- Star
- 118
- Fork
- 52
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của w3c/FileAPI
-
TPAC 2026 Status ReportĐang mởTPAC2026
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Broken references in File APIĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
-
Add accessibility sectionĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
alphaonelabs/learn#87 ·
-
status/needs-triage type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
PKU-YuanGroup/OpenAI4S#218 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ux waiting for feedback
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
evcc-io/evcc#34527 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
BU-Spark/se-chem-apll#47 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày