@braintree/asset-loader 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/load-script.js +1 -2
- package/dist/load-stylesheet.d.ts +0 -1
- package/dist/load-stylesheet.js +2 -3
- package/package.json +2 -4
- package/dist/lib/promise.d.ts +0 -2
- package/dist/lib/promise.js +0 -11
package/dist/load-script.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var promise_1 = require("./lib/promise");
|
|
3
2
|
var scriptPromiseCache = {};
|
|
4
3
|
function loadScript(options) {
|
|
5
4
|
var scriptLoadPromise;
|
|
@@ -25,7 +24,7 @@ function loadScript(options) {
|
|
|
25
24
|
Object.keys(attrs).forEach(function (key) {
|
|
26
25
|
script.setAttribute("data-".concat(key), "".concat(attrs[key]));
|
|
27
26
|
});
|
|
28
|
-
scriptLoadPromise = new
|
|
27
|
+
scriptLoadPromise = new Promise(function (resolve, reject) {
|
|
29
28
|
script.addEventListener("load", function () {
|
|
30
29
|
resolve(script);
|
|
31
30
|
});
|
package/dist/load-stylesheet.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var promise_1 = require("./lib/promise");
|
|
3
2
|
module.exports = function loadStylesheet(options) {
|
|
4
3
|
var stylesheet = document.querySelector("link[href=\"".concat(options.href, "\"]"));
|
|
5
4
|
if (stylesheet) {
|
|
6
|
-
return
|
|
5
|
+
return Promise.resolve(stylesheet);
|
|
7
6
|
}
|
|
8
7
|
stylesheet = document.createElement("link");
|
|
9
8
|
var container = options.container || document.head;
|
|
@@ -17,5 +16,5 @@ module.exports = function loadStylesheet(options) {
|
|
|
17
16
|
else {
|
|
18
17
|
container.appendChild(stylesheet);
|
|
19
18
|
}
|
|
20
|
-
return
|
|
19
|
+
return Promise.resolve(stylesheet);
|
|
21
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@braintree/asset-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A module to load frontend assets.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,9 +41,7 @@
|
|
|
41
41
|
"ts-jest": "^29.1.1",
|
|
42
42
|
"typescript": "^5.1.6"
|
|
43
43
|
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"promise-polyfill": "^8.3.0"
|
|
46
|
-
},
|
|
44
|
+
"dependencies": {},
|
|
47
45
|
"jest": {
|
|
48
46
|
"testEnvironment": "jsdom",
|
|
49
47
|
"clearMocks": true,
|
package/dist/lib/promise.d.ts
DELETED
package/dist/lib/promise.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PromiseGlobal = void 0;
|
|
7
|
-
var promise_polyfill_1 = __importDefault(require("promise-polyfill"));
|
|
8
|
-
var PromiseGlobal =
|
|
9
|
-
// eslint-disable-next-line no-undef
|
|
10
|
-
typeof Promise !== "undefined" ? Promise : promise_polyfill_1.default;
|
|
11
|
-
exports.PromiseGlobal = PromiseGlobal;
|