Commit fa987435fa72393d88537413ed65dd536014438d

Andreas Rohner 2016-01-26T23:10:45

Use document.currentScript instead of document.getElementsByTagName()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/components/prism-core.js b/components/prism-core.js
index 50d5fbc..e8ece18 100644
--- a/components/prism-core.js
+++ b/components/prism-core.js
@@ -410,10 +410,8 @@ if (!_self.document) {
 	return _self.Prism;
 }
 
-// Get current script and highlight
-var script = document.getElementsByTagName('script');
-
-script = script[script.length - 1];
+//Get current script and highlight
+var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
 
 if (script) {
 	_.filename = script.src;