From be0757494fa18b49e738ca7b4dae3d50f63f8ab4 Mon Sep 17 00:00:00 2001 From: yannick-milanetto Date: Tue, 27 Jun 2017 15:08:52 +0200 Subject: [PATCH] Fix Interchange when replacing background image containing parenthesis --- js/foundation.interchange.js | 1 + test/javascript/components/interchange.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 js/foundation.interchange.js mode change 100644 => 100755 test/javascript/components/interchange.js diff --git a/js/foundation.interchange.js b/js/foundation.interchange.js old mode 100644 new mode 100755 index 00ce66dc3..fb82e1e7c --- a/js/foundation.interchange.js +++ b/js/foundation.interchange.js @@ -157,6 +157,7 @@ class Interchange extends Plugin { } // Replacing background images else if (path.match(/\.(gif|jpg|jpeg|png|svg|tiff)([?#].*)?/i)) { + path = path.replace(/\(/g, '%28').replace(/\)/g, '%29'); this.$element.css({ 'background-image': 'url('+path+')' }) .trigger(trigger); } diff --git a/test/javascript/components/interchange.js b/test/javascript/components/interchange.js old mode 100644 new mode 100755 index afc8d634d..f38a57e02 --- a/test/javascript/components/interchange.js +++ b/test/javascript/components/interchange.js @@ -12,7 +12,7 @@ describe('Interchange', function() { switch (type) { case 'image': case 'background': - return `_build/assets/img/interchange/${size}.jpg`; + return `_build/assets/img/interchange/strip_icc()/${size}.jpg`; default: return `_build/assets/partials/interchange-${size}.html`; } @@ -79,7 +79,7 @@ describe('Interchange', function() { plugin.replace(getPath('background', 'large')); - $html[0].style.backgroundImage.should.contain(getPath('background', 'large')); + $html[0].style.backgroundImage.should.contain(getPath('background', 'large').replace(/\(/g, '%28').replace(/\)/g, '%29')); }); it('replaces contents of div with templates', function() { @@ -132,7 +132,7 @@ describe('Interchange', function() { plugin.rules.length.should.be.equal(3); }); - it('extracts special queries from the plugin element', function() { + it('extracts special queries from the plugin element', function() { $html = $(generateTemplate('image')).attr('data-interchange', '[image.png, retina]').appendTo('body'); plugin = new Foundation.Interchange($html, {}); -- 2.47.2