Blob has no text() function in Safari 14 on iOS

Viewed 21

I'm using a WKWebView on iOS to render an SVG. The SVG is created like this simplified example in a third-party library:

var svgBlob = new Blob(['<?xml version="1.0" standalone="no"?>\r\n' + '<svg height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>'], { type: "image/svg+xml" });

My code then tries to obtain the raw SVG text like this:

var svgText = await svgBlob.text();

On Safari 15 and higher, everything works as expected—-the SVG data is returned—-but on Safari 14, I get the error svgBlob.text() is not a function. Upon further inspection, svgBlob is in fact a blob, has a size, a type, and a slice function, but no other properties. The text property/function doesn't even exist.

MDN indicates that this API has existed on Safari on iOS since v14, and there are no caveats listed.

Is there some sort of trick to making this work?

0 Answers
Related