Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fab9b2d

Browse files
committedNov 21, 2018
use context._baseUrl / add jsDoc to Drawing.setClipUrl
1 parent 29fdf45 commit fab9b2d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
 

‎src/components/drawing/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,17 @@ function nodeHash(node) {
10001000
node.getAttribute('style');
10011001
}
10021002

1003-
/*
1004-
* make a robust clipPath url from a local id
1005-
* note! We'd better not be exporting from a page
1006-
* with a <base> or the svg will not be portable!
1003+
/**
1004+
* Set clipPath URL in a way that work for all situations.
1005+
*
1006+
* In details, graphs on pages with <base> HTML tags need to prepend
1007+
* the clip path ids with the page's base url EXCEPT during toImage exports.
1008+
*
1009+
* @param {d3 selection} s : node to add clip-path attribute
1010+
* @param {string} localId : local clip-path (w/o base url) id
1011+
* @param {DOM element || object} gd
1012+
* - context._baseUrl {string}
1013+
* - context._exportedPlot {boolean}
10071014
*/
10081015
drawing.setClipUrl = function(s, localId, gd) {
10091016
if(!localId) {
@@ -1012,7 +1019,7 @@ drawing.setClipUrl = function(s, localId, gd) {
10121019
}
10131020

10141021
var context = gd._context;
1015-
var baseUrl = context._exportedPlot ? '' : (context.baseUrl || '');
1022+
var baseUrl = context._exportedPlot ? '' : (context._baseUrl || '');
10161023

10171024
s.attr('clip-path', 'url(' + baseUrl + '#' + localId + ')');
10181025
};

‎src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ function setPlotContext(gd, config) {
421421

422422
// stash <base> href, used to make robust clipPath URLs
423423
var base = d3.select('base');
424-
gd._context.baseUrl = base.size() && base.attr('href') ?
424+
gd._context._baseUrl = base.size() && base.attr('href') ?
425425
window.location.href.split('#')[0] :
426426
'';
427427
}

0 commit comments

Comments
 (0)
Please sign in to comment.