8000 Fixup misinterpreted clip-path by some programs after export by archmoj · Pull Request #5686 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Fixup misinterpreted clip-path by some programs after export #5686

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
keep quotes in the case of base url
  • Loading branch information
archmoj committed May 26, 2021
commit 3a5d532644540fcbc3cb800f175e6d81a2873465
4 changes: 3 additions & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,9 @@ function getFullUrl(localId, gd) {

var context = gd._context;
var baseUrl = context._exportedPlot ? '' : (context._baseUrl || '');
return 'url(' + baseUrl + '#' + localId + ')';
return baseUrl ?
'url(\'' + baseUrl + '#' + localId + '\')' :
'url(#' + localId + ')';
}

drawing.getTranslate = function(element) {
Expand Down
6 changes: 3 additions & 3 deletions test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Drawing', function() {
});

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

Drawing.setClipUrl(this.g, false);

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

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

base.remove();
});
Expand All @@ -64,7 +64,7 @@ describe('Drawing', function() {

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ describe('plot svg clip paths', function() {
d3SelectAll('[clip-path]').each(function() {
var cp = d3Select(this).attr('clip-path');

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

base.remove();
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/snapshot_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Plotly.Snapshot', function() {

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

Expand Down
0