[Pkg-javascript-commits] [pdf.js] 130/174: Uses document.currentScript for pdf.worker.js path.

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:31 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 28d340679a4bb767e244e2a2b8840a1b5487df78
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Thu Nov 5 19:30:59 2015 -0600

    Uses document.currentScript for pdf.worker.js path.
---
 src/pdf.js           |  6 ++----
 web/compatibility.js | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/pdf.js b/src/pdf.js
index 694891c..6d838eb 100644
--- a/src/pdf.js
+++ b/src/pdf.js
@@ -42,10 +42,8 @@ if (!PDFJS.workerSrc && typeof document !== 'undefined') {
   // workerSrc is not set -- using last script url to define default location
   PDFJS.workerSrc = (function () {
     'use strict';
-    var scriptTagContainer = document.body ||
-                             document.getElementsByTagName('head')[0];
-    var pdfjsSrc = scriptTagContainer.lastChild.src;
-    return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
+    var pdfJsSrc = document.currentScript.src;
+    return pdfJsSrc && pdfJsSrc.replace(/\.js$/i, '.worker.js');
   })();
 }
 //#endif
diff --git a/web/compatibility.js b/web/compatibility.js
index 6d91057..594c20b 100644
--- a/web/compatibility.js
+++ b/web/compatibility.js
@@ -577,3 +577,19 @@ if (typeof PDFJS === 'undefined') {
     PDFJS.disableFullscreen = true;
   }
 })();
+
+// Provides document.currentScript support
+// Support: IE, Chrome<29.
+(function checkCurrentScript() {
+  if ('currentScript' in document) {
+    return;
+  }
+  Object.defineProperty(document, 'currentScript', {
+    get: function () {
+      var scripts = document.getElementsByTagName('script');
+      return scripts[scripts.length - 1];
+    },
+    enumerable: true,
+    configurable: true
+  });
+})();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list