Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ drawing.setClipUrl = function(s, localId) {
var url = '#' + localId,
base = d3.select('base');

if(base.size() && base.attr('href')) url = window.location.href + url;
// add id to location href w/o hashes if any)
if(base.size() && base.attr('href')) {
url = window.location.href.split('#')[0] + url;
}

s.attr('clip-path', 'url(' + url + ')');
};
17 changes: 17 additions & 0 deletions test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,21 @@ describe('Drawing.setClipUrl', function() {

base.remove();
});

it('should append window URL w/o hash to clip-path if <base> is present', function() {
var base = d3.select('body')
.append('base')
.attr('href', 'https://plot.ly/#hash');

window.location.hash = 'hash';

Drawing.setClipUrl(this.g, 'id4');

var expected = 'url(' + window.location.href.split('#')[0] + '#id4)';

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

base.remove();
window.location.hash = '';
});
});
2 changes: 1 addition & 1 deletion test/jasmine/tests/plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ describe('plot svg clip paths', function() {
.attr('href', 'https://plot.ly');

// grab window URL
var href = window.location.href;
var href = window.location.href.split('#')[0];

plot().then(function() {

Expand Down