Skip to content

Commit 3a5d532

Browse files
committed
keep quotes in the case of base url
1 parent aa1622f commit 3a5d532

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/components/drawing/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,9 @@ function getFullUrl(localId, gd) {
12701270

12711271
var context = gd._context;
12721272
var baseUrl = context._exportedPlot ? '' : (context._baseUrl || '');
1273-
return 'url(' + baseUrl + '#' + localId + ')';
1273+
return baseUrl ?
1274+
'url(\'' + baseUrl + '#' + localId + '\')' :
1275+
'url(#' + localId + ')';
12741276
}
12751277

12761278
drawing.getTranslate = function(element) {

test/jasmine/tests/drawing_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Drawing', function() {
2929
});
3030

3131
it('should unset the clip-path if arg is falsy', function() {
32-
this.g.attr('clip-path', 'url(#id2)');
32+
this.g.attr('clip-path', 'url(\'#id2\')');
3333

3434
Drawing.setClipUrl(this.g, false);
3535

@@ -48,7 +48,7 @@ describe('Drawing', function() {
4848
Drawing.setClipUrl(this.g, 'id3', {_context: {_baseUrl: href}});
4949

5050
expect(this.g.attr('clip-path'))
51-
.toEqual('url(' + href + '#id3)');
51+
.toEqual('url(\'' + href + '#id3\')');
5252

5353
base.remove();
5454
});
@@ -64,7 +64,7 @@ describe('Drawing', function() {
6464

6565
Drawing.setClipUrl(this.g, 'id4', {_context: {_baseUrl: href2}});
6666

67-
var expected = 'url(' + href2 + '#id4)';
67+
var expected = 'url(\'' + href2 + '#id4\')';
6868

6969
expect(this.g.attr('clip-path')).toEqual(expected);
7070

test/jasmine/tests/plot_interact_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ describe('plot svg clip paths', function() {
568568
d3SelectAll('[clip-path]').each(function() {
569569
var cp = d3Select(this).attr('clip-path');
570570

571-
expect(cp.substring(0, 5 + href.length)).toEqual('url(' + href + '#');
572-
expect(cp.substring(cp.length - 1)).toEqual(')');
571+
expect(cp.substring(0, 6 + href.length)).toEqual('url(\'' + href + '#');
572+
expect(cp.substring(cp.length - 2)).toEqual('\')');
573573
});
574574

575575
base.remove();

test/jasmine/tests/snapshot_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('Plotly.Snapshot', function() {
251251

252252
describe('should handle quoted style properties', function() {
253253
function checkURL(actual, msg) {
254-
// which is enough to check that toSVG did its job right
254+
// which is enough tot check that toSVG did its job right
255255
expect((actual || '').substr(0, 6)).toBe('url(\"#', msg);
256256
}
257257

0 commit comments

Comments
 (0)