File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -568,6 +568,10 @@ drawing.setClipUrl = function(s, localId) {
568568 var url = '#' + localId ,
569569 base = d3 . select ( 'base' ) ;
570570
571- if ( base . size ( ) && base . attr ( 'href' ) ) url = window . location . href + url ;
571+ // add id to location href w/o hashes if any)
572+ if ( base . size ( ) && base . attr ( 'href' ) ) {
573+ url = window . location . href . split ( '#' ) [ 0 ] + url ;
574+ }
575+
572576 s . attr ( 'clip-path' , 'url(' + url + ')' ) ;
573577} ;
Original file line number Diff line number Diff line change @@ -49,4 +49,21 @@ describe('Drawing.setClipUrl', function() {
4949
5050 base . remove ( ) ;
5151 } ) ;
52+
53+ it ( 'should append window URL w/o hash to clip-path if <base> is present' , function ( ) {
54+ var base = d3 . select ( 'body' )
55+ . append ( 'base' )
56+ . attr ( 'href' , 'https://plot.ly/#hash' ) ;
57+
58+ window . location . hash = 'hash' ;
59+
60+ Drawing . setClipUrl ( this . g , 'id4' ) ;
61+
62+ var expected = 'url(' + window . location . href . split ( '#' ) [ 0 ] + '#id4)' ;
63+
64+ expect ( this . g . attr ( 'clip-path' ) ) . toEqual ( expected ) ;
65+
66+ base . remove ( ) ;
67+ window . location . hash = '' ;
68+ } ) ;
5269} ) ;
You can’t perform that action at this time.
0 commit comments