@@ -1000,32 +1000,28 @@ function nodeHash(node) {
1000
1000
node . getAttribute ( 'style' ) ;
1001
1001
}
1002
1002
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}
1007
1014
*/
1008
- drawing . setClipUrl = function ( s , localId ) {
1015
+ drawing . setClipUrl = function ( s , localId , gd ) {
1009
1016
if ( ! localId ) {
1010
1017
s . attr ( 'clip-path' , null ) ;
1011
1018
return ;
1012
1019
}
1013
1020
1014
- if ( drawing . baseUrl === undefined ) {
1015
- var base = d3 . select ( 'base' ) ;
1016
-
1017
- // Stash base url once and for all!
1018
- // We may have to stash this elsewhere when
1019
- // we'll try to support for child windows
1020
- // more info -> https://github.com/plotly/plotly.js/issues/702
1021
- if ( base . size ( ) && base . attr ( 'href' ) ) {
1022
- drawing . baseUrl = window . location . href . split ( '#' ) [ 0 ] ;
1023
- } else {
1024
- drawing . baseUrl = '' ;
1025
- }
1026
- }
1021
+ var context = gd . _context ;
1022
+ var baseUrl = context . _exportedPlot ? '' : ( context . _baseUrl || '' ) ;
1027
1023
1028
- s . attr ( 'clip-path' , 'url(' + drawing . baseUrl + '#' + localId + ')' ) ;
1024
+ s . attr ( 'clip-path' , 'url(' + baseUrl + '#' + localId + ')' ) ;
1029
1025
} ;
1030
1026
1031
1027
drawing . getTranslate = function ( element ) {
0 commit comments