From 3fcf079ed12f6fd8584a735a7f520c3b17370cab Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Mon, 2 Dec 2013 12:14:26 +0100 Subject: [PATCH] use el.getAttribute instead of el.dataset to support IE10 m( --- isso/js/app/api.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/isso/js/app/api.js b/isso/js/app/api.js index 23e3102..a2736fb 100644 --- a/isso/js/app/api.js +++ b/isso/js/app/api.js @@ -31,25 +31,21 @@ define(["q"], function(Q) { * .. code-block:: html * * - * - * 2. use require.js (during development). When using require.js, we - * assume that the path to the scripts ends with `/js/`. */ var script, endpoint, js = document.getElementsByTagName("script"); for (var i = 0; i < js.length; i++) { - if (js[i].dataset.isso !== undefined) { - endpoint = js[i].dataset.isso; - } else if (js[i].src.match("require\\.js$")) { - endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, ""); + if (js[i].hasAttribute("data-isso")) { + endpoint = js[i].getAttribute("data-isso"); + break; } } if (! endpoint) { 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 " + "refer to https://github.com/posativ/isso#client-configuration " + "and add a custom `data-isso` attribute."; @@ -57,14 +53,10 @@ define(["q"], function(Q) { } script = js[js.length - 1]; - - if (script.dataset.prefix) { - endpoint = script.dataset.prefix; - } else { - endpoint = script.src.substring(0, script.src.length - "/js/embed.min.js".length); - } + endpoint = script.src.substring(0, script.src.length - "/js/embed.min.js".length); } + // strip trailing slash if (endpoint[endpoint.length - 1] === "/") { endpoint = endpoint.substring(0, endpoint.length - 1); }