From 8b787ac80377819086c1c3f03fb3eb40e622b5c4 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 22 Jan 2020 11:55:57 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20unnecessary=20"unsaved?= =?UTF-8?q?=20changes"=20modal=20when=20using=20HR=20cards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - the `hr` mobiledoc card does not specify an `absoluteToRelative` or `relativeToAbsolute` transformer function so falls back to the default transformer - the default transformer function's arguments were not correct which meant that the UrlUtils object was replacing the card's typical empty-object payload - the card's payload changing when saving mobiledoc was triggering the editor's unsaved changes warning because the API response no longer matched what was in the editor --- core/server/lib/mobiledoc/create-card.js | 2 +- core/test/unit/lib/mobiledoc/cards/hr_spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/server/lib/mobiledoc/create-card.js b/core/server/lib/mobiledoc/create-card.js index 8049469b1c..44ba8d61f9 100644 --- a/core/server/lib/mobiledoc/create-card.js +++ b/core/server/lib/mobiledoc/create-card.js @@ -1,7 +1,7 @@ let urlUtils; module.exports = function createCard(card) { - const defaultTransformer = function (payload) { + const defaultTransformer = function (urlUtils, payload) { return payload; }; diff --git a/core/test/unit/lib/mobiledoc/cards/hr_spec.js b/core/test/unit/lib/mobiledoc/cards/hr_spec.js index 8d75301f6e..679b87b602 100644 --- a/core/test/unit/lib/mobiledoc/cards/hr_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/hr_spec.js @@ -13,4 +13,16 @@ describe('HR card', function () { serializer.serialize(card.render(opts)).should.match('
'); }); + + it('transforms urls absolute to relative', function () { + let payload = {}; + const transformed = card.absoluteToRelative(payload, {}); + transformed.should.deepEqual({}); + }); + + it('transforms urls relative to absolute', function () { + let payload = {}; + const transformed = card.relativeToAbsolute(payload, {}); + transformed.should.deepEqual({}); + }); });