diff --git a/packages/dom/src/serialize-base64.js b/packages/dom/src/serialize-base64.js
index c287e3f82..0a25369d8 100644
--- a/packages/dom/src/serialize-base64.js
+++ b/packages/dom/src/serialize-base64.js
@@ -14,10 +14,17 @@ function getBase64Substring(src) {
export function serializeBase64(node, resources) {
let src = node.src;
+ let isHrefUsed = false;
+
+ // case for SVGAnimatedString
+ if (src == null && node.href) {
+ isHrefUsed = true;
+ src = node.href.baseVal;
+ }
// skip if src is null
if (src == null) return;
- let base64String = getBase64Substring(src);
+ let base64String = getBase64Substring(src.toString());
// skip if src is not base64
if (base64String == null) return;
@@ -25,7 +32,11 @@ export function serializeBase64(node, resources) {
let resource = resourceFromText(uid(), mimetype, base64String);
resources.add(resource);
- node.src = resource.url;
+ if (isHrefUsed === true) {
+ node.href.baseVal = resource.url;
+ } else {
+ node.src = resource.url;
+ }
}
export default serializeBase64;
diff --git a/packages/dom/test/serialize-base64.test.js b/packages/dom/test/serialize-base64.test.js
index 2d2c1e53d..636e9d348 100644
--- a/packages/dom/test/serialize-base64.test.js
+++ b/packages/dom/test/serialize-base64.test.js
@@ -22,6 +22,26 @@ describe('serializeBase64', () => {
}));
});
+ it(`${platform}: serializes SVGAnimatedString having base64`, async () => {
+ withExample(`
+
+ `);
+
+ serialized = serializeDOM();
+ $ = parseDOM(serialized.html, platform);
+
+ expect($('#image')[0].getAttribute('href'))
+ .toMatch('/__serialized__/\\w+\\.png');
+ expect(serialized.resources).toContain(jasmine.objectContaining({
+ url: $('#image')[0].getAttribute('href'),
+ content: 'iVBORw0KGgoAAAANSUhEU',
+ mimetype: 'image/png'
+ }));
+ });
+
it(`${platform}: does not serialize elements without any src`, async () => {
withExample(`