simple-load-script
Advanced tools
Comparing version 1.0.1 to 1.0.2
# changelog | ||
## x.x.x | ||
## 1.0.2 | ||
* added `insertInto` config option | ||
## 1.0.1 | ||
* rename index.js | ||
* readme | ||
@@ -6,0 +10,0 @@ * changes in `all` method |
{ | ||
"name": "simple-load-script", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Very simple promise based script and JSONP", | ||
@@ -15,5 +15,5 @@ "repository": "tomek-f/simple-load-script", | ||
"main": "simpleLoadScript.js", | ||
"author": "Tomek Fijoł", | ||
"author": "Tomek Fijoł <tomekfijol@gmail.com> (http://tomekf.pl/)", | ||
"license": "MIT", | ||
"readmeFilename": "README.md" | ||
} |
@@ -152,2 +152,3 @@ # simple-load-script | ||
* `removeScript` (boolean) - after load (for JSONP, other reasons); it's always removed on error | ||
* `insertInto` (string) - [CSS selector (an ID, class name, element name, etc.)](https://developer.mozilla.org/en/docs/Web/API/Document/querySelector) to insert the script into. Overrides `inBody` value. | ||
@@ -154,0 +155,0 @@ ## Returned values |
@@ -10,3 +10,2 @@ (function (root, factory) { | ||
}(this, function () { | ||
var undef; | ||
@@ -34,3 +33,12 @@ | ||
var script = document.createElement('script'); | ||
var where = options.inBody ? document.body : document.head; | ||
var where = (function () { | ||
if (options.insertInto) { | ||
return document.querySelector(options.insertInto); | ||
} | ||
return options.inBody ? document.body : document.head; | ||
}()); | ||
if (!where) { | ||
reject('Error: no DOM element to append script'); | ||
return; | ||
} | ||
var attrs = options.attrs; | ||
@@ -78,3 +86,2 @@ var removeScript = options.removeScript; | ||
return getScript; | ||
})); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8961
79
204