lewisje / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

Default to src path when no data-path #565

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using systems which build script nodes or otherwise don't allow for the 
use of a data-path the src= attribute of the script tag referencing the svg.js 
file can be used. A patch would be similar to the following block of code, 
which is from roughly line 1209 in the current svg.js file:

    var scripts = document.getElementsByTagName('script');
    for (var i = 0; i < scripts.length; i++) {
      if (/svg(?:\-uncompressed)?\.js/.test(scripts[i].src)) {
        //  If the user didn't/couldn't supply a data-path then we'll try to
        //  use the path from the .js file itself, found in the src attribute.
        if (scripts[i].getAttribute('data-path')) {
          libraryPath = scripts[i].getAttribute('data-path');
        } else {
          var fullPath = scripts[i].getAttribute('src');
          var parts = fullPath.split('/');
          parts.length = parts.length - 1;
          libraryPath = parts.join('/');
        }
        break;
      }
    }

Original issue reported on code.google.com by Scott.Sh...@gmail.com on 7 Nov 2010 at 9:35

GoogleCodeExporter commented 8 years ago
Christian Heilmann made a similar suggestion. It's a good idea.

Original comment by bradneub...@gmail.com on 16 Nov 2010 at 10:23

GoogleCodeExporter commented 8 years ago
Fixed in r1268.

Original comment by grick23@gmail.com on 29 Nov 2010 at 5:42