From 07dc190e3424e0c3b71d3b0be099d4f2ce35bcaa Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 5 Apr 2019 17:26:38 +0200 Subject: [PATCH] Modernize Blob constructor a tiny bit All implementations do something different for new Blob(undefined, { type: "x/x" }). Let's do something simple. Fixes #54. --- index.bs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/index.bs b/index.bs index b2e321a..ec1f61e 100644 --- a/index.bs +++ b/index.bs @@ -222,7 +222,7 @@ Further normative definition of snapshot state can be found for {{File}}s [Exposed=(Window,Worker), Serializable] interface Blob { - constructor(optional sequence<BlobPart> blobParts, + constructor(optional sequence<BlobPart> blobParts = [], optional BlobPropertyBag options = {}); readonly attribute unsigned long long size; @@ -287,28 +287,22 @@ which runs these steps: ## Constructors ## {#constructorBlob} <div algorithm="blob-constructor"> -The {{Blob()}} constructor can be invoked with zero or more parameters. When the {{Blob()}} constructor is invoked, user agents must run the following steps: -1. If invoked with zero parameters, - return a new {{Blob}} object consisting of 0 bytes, - with {{Blob/size}} set to 0, - and with {{Blob/type}} set to the empty string. - 1. Let |bytes| be the result of [=processing blob parts=] given {{blobParts}} and {{Blob/Blob(blobParts, options)/options}}. -1. If the {{BlobPropertyBag/type}} member of the {{Blob/Blob(blobParts, options)/options}} argument is not the empty string, - run the following sub-steps: +1. Let |t| be the empty string. + +1. If {{Blob/Blob(blobParts, options)/options}}["{{BlobPropertyBag/type}}"] does not contain any characters outside the range U+0020 to U+007E, inclusive, then: + + 1. Set |t| to {{Blob/Blob(blobParts, options)/options}}["{{BlobPropertyBag/type}}"]. - 1. Let |t| be the {{BlobPropertyBag/type}} dictionary member. - If |t| contains any characters outside the range U+0020 to U+007E, - then set |t| to the empty string and return from these substeps. 1. Convert every character in |t| to [=ASCII lowercase=]. 1. Return a {{Blob}} object referring to |bytes| as its associated <a>byte</a> sequence, with its {{Blob/size}} set to the length of |bytes|, - and its {{Blob/type}} set to the value of |t| from the substeps above. + and its {{Blob/type}} set to |t|. </div> @@ -1769,6 +1763,6 @@ This specification was originally developed by the SVG Working Group. Many thank Thanks to Robin Berjon, Jonas Sicking and Vsevolod Shmyroff for editing the original specification. -Special thanks to Olli Pettay, Nikunj Mehta, Garrett Smith, Aaron Boodman, Michael Nordman, Jian Li, Dmitry Titov, Ian Hickson, Darin Fisher, Sam Weinig, Adrian Bateman and Julian Reschke. +Special thanks to Boris Zbarsky, Olli Pettay, Nikunj Mehta, Garrett Smith, Aaron Boodman, Michael Nordman, Jian Li, Dmitry Titov, Ian Hickson, Darin Fisher, Sam Weinig, Adrian Bateman, and Julian Reschke. Thanks to the W3C WebApps WG, and to participants on the public-webapps@w3.org listserv