use el.getAttribute instead of el.dataset to support IE10 m(

pull/41/head
Martin Zimmermann 11 years ago
parent 59b70e7109
commit 83b48d5db6

@ -31,25 +31,21 @@ define(["q"], function(Q) {
* .. code-block:: html * .. code-block:: html
* *
* <script data-isso="http://example.tld/path/" src="/.../embed.min.js"></script> * <script data-isso="http://example.tld/path/" src="/.../embed.min.js"></script>
*
* 2. use require.js (during development). When using require.js, we
* assume that the path to the scripts ends with `/js/`.
*/ */
var script, endpoint, var script, endpoint,
js = document.getElementsByTagName("script"); js = document.getElementsByTagName("script");
for (var i = 0; i < js.length; i++) { for (var i = 0; i < js.length; i++) {
if (js[i].dataset.isso !== undefined) { if (js[i].hasAttribute("data-isso")) {
endpoint = js[i].dataset.isso; endpoint = js[i].getAttribute("data-isso");
} else if (js[i].src.match("require\\.js$")) { break;
endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, "");
} }
} }
if (! endpoint) { if (! endpoint) {
for (i = 0; i < js.length; i++) { for (i = 0; i < js.length; i++) {
if (js[i].hasAttribute("async") || js[i].hasAttribute("defer")) { if (js[i].getAttribute("async") || js[i].getAttribute("defer")) {
throw "Isso's automatic configuration detection failed, please " + throw "Isso's automatic configuration detection failed, please " +
"refer to https://github.com/posativ/isso#client-configuration " + "refer to https://github.com/posativ/isso#client-configuration " +
"and add a custom `data-isso` attribute."; "and add a custom `data-isso` attribute.";
@ -57,14 +53,10 @@ define(["q"], function(Q) {
} }
script = js[js.length - 1]; script = js[js.length - 1];
endpoint = script.src.substring(0, script.src.length - "/js/embed.min.js".length);
if (script.dataset.prefix) {
endpoint = script.dataset.prefix;
} else {
endpoint = script.src.substring(0, script.src.length - "/js/embed.min.js".length);
}
} }
// strip trailing slash
if (endpoint[endpoint.length - 1] === "/") { if (endpoint[endpoint.length - 1] === "/") {
endpoint = endpoint.substring(0, endpoint.length - 1); endpoint = endpoint.substring(0, endpoint.length - 1);
} }

Loading…
Cancel
Save