From abc6a86099d00cc26be9042992ceb274f32d9661 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Mon, 26 Sep 2016 19:57:35 +1300 Subject: [PATCH] fix(cards): imagesUrl when module is loaded asychronously --- README.md | 12 +++--------- cards.js | 7 ++++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e254e8e..826ec3b 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,12 @@ Install with [npm](http://blog.npmjs.org/post/85484771375/how-to-install-npm) ### Browser -Include the package from your project - -````html - - -```` - -or from the [unpkg CDN](https://unpkg.com) +Include the package from the [unpkg CDN](https://unpkg.com) ````html - + + ```` ## Cards diff --git a/cards.js b/cards.js index a28b7ae..6367957 100644 --- a/cards.js +++ b/cards.js @@ -1,5 +1,7 @@ /*jslint vars: true, plusplus: true, -W003 */ /*globals window, document, define, exports, module, require */ + +var cardsScript = document.currentScript; (function (root, factory) { 'use strict'; @@ -302,9 +304,8 @@ }); // Default imagesUrl to a subfolder of the script source. - var mySource = document.currentScript.src; - if (mySource) { - var path = mySource.substring(0, mySource.lastIndexOf('/')) + '/cards/'; + if (cardsScript && cardsScript.src) { + var path = cardsScript.src.substring(0, cardsScript.src.lastIndexOf('/')) + '/cards/'; module.options.imagesUrl = path; }