@braintree/asset-loader 0.4.4 → 1.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.
@@ -16,21 +16,24 @@ function loadScript(options) {
16
16
  script.src = options.src;
17
17
  script.id = options.id || "";
18
18
  script.async = true;
19
+ if (options.type) {
20
+ script.setAttribute("type", "".concat(options.type));
21
+ }
19
22
  if (options.crossorigin) {
20
- script.setAttribute("crossorigin", "" + options.crossorigin);
23
+ script.setAttribute("crossorigin", "".concat(options.crossorigin));
21
24
  }
22
25
  Object.keys(attrs).forEach(function (key) {
23
- script.setAttribute("data-" + key, "" + attrs[key]);
26
+ script.setAttribute("data-".concat(key), "".concat(attrs[key]));
24
27
  });
25
28
  scriptLoadPromise = new promise_1.PromiseGlobal(function (resolve, reject) {
26
29
  script.addEventListener("load", function () {
27
30
  resolve(script);
28
31
  });
29
32
  script.addEventListener("error", function () {
30
- reject(new Error(options.src + " failed to load."));
33
+ reject(new Error("".concat(options.src, " failed to load.")));
31
34
  });
32
35
  script.addEventListener("abort", function () {
33
- reject(new Error(options.src + " has aborted."));
36
+ reject(new Error("".concat(options.src, " has aborted.")));
34
37
  });
35
38
  container.appendChild(script);
36
39
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var promise_1 = require("./lib/promise");
3
3
  module.exports = function loadStylesheet(options) {
4
- var stylesheet = document.querySelector("link[href=\"" + options.href + "\"]");
4
+ var stylesheet = document.querySelector("link[href=\"".concat(options.href, "\"]"));
5
5
  if (stylesheet) {
6
6
  return promise_1.PromiseGlobal.resolve(stylesheet);
7
7
  }
package/dist/types.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- export declare type LoadScriptOptions = {
1
+ export type LoadScriptOptions = {
2
2
  container?: HTMLElement;
3
3
  crossorigin?: boolean | string;
4
4
  dataAttributes?: Record<string, string | number>;
5
5
  forceScriptReload?: boolean;
6
6
  src: string;
7
+ type?: string;
7
8
  id?: string;
8
9
  };
9
- export declare type LoadStylesheetOptions = {
10
+ export type LoadStylesheetOptions = {
10
11
  href: string;
11
12
  container?: HTMLElement;
12
13
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braintree/asset-loader",
3
- "version": "0.4.4",
3
+ "version": "1.0.1",
4
4
  "description": "A module to load frontend assets.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,24 +29,28 @@
29
29
  },
30
30
  "homepage": "https://github.com/braintree/asset-loader#readme",
31
31
  "devDependencies": {
32
- "@types/jest": "^26.0.5",
33
- "@types/promise-polyfill": "^6.0.3",
34
- "eslint": "^7.5.0",
35
- "eslint-config-braintree": "^5.0.0-typescript-prep-rc.17",
36
- "jest": "^26.1.0",
37
- "prettier": "^2.0.5",
38
- "ts-jest": "^26.1.3",
39
- "typescript": "^3.9.7"
32
+ "@types/jest": "^29.5.3",
33
+ "@types/promise-polyfill": "^6.0.4",
34
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
35
+ "eslint": "^8.47.0",
36
+ "eslint-config-braintree": "^6.0.0-typescript-prep-rc.2",
37
+ "eslint-plugin-prettier": "^5.0.0",
38
+ "jest": "^29.6.3",
39
+ "jest-environment-jsdom": "^29.6.3",
40
+ "prettier": "^3.0.2",
41
+ "ts-jest": "^29.1.1",
42
+ "typescript": "^5.1.6"
40
43
  },
41
44
  "dependencies": {
42
- "promise-polyfill": "^8.1.3"
45
+ "promise-polyfill": "^8.3.0"
43
46
  },
44
47
  "jest": {
48
+ "testEnvironment": "jsdom",
45
49
  "clearMocks": true,
46
50
  "preset": "ts-jest",
47
51
  "globals": {
48
52
  "ts-jest": {
49
- "tsConfig": "src/__tests__/tsconfig.test.json"
53
+ "tsconfig": "src/__tests__/tsconfig.test.json"
50
54
  }
51
55
  }
52
56
  }
package/CHANGELOG.md DELETED
@@ -1,39 +0,0 @@
1
- # 0.4.4
2
-
3
- - Fix issue where server side rendering would not work with sdk
4
-
5
- # 0.4.3
6
-
7
- - Remove use of `export default` in promise lib
8
-
9
- # 0.4.2
10
-
11
- - Remove use of `export default` in module
12
-
13
- # 0.4.1
14
-
15
- - Fix paths when publishing
16
-
17
- # 0.4.0
18
-
19
- - Add typescript types
20
-
21
- # 0.3.1
22
-
23
- - Fix issue where crossorigin would not be set
24
-
25
- # 0.3.0
26
-
27
- - Add ability to set crossorigin attribute
28
-
29
- # 0.2.1
30
-
31
- - Set `loadScript` to cache the promise used to load the script to eliiminate a race condition where the script could be on the page, but not ready to use
32
-
33
- # 0.2.0
34
-
35
- - Add ability to force reload a script tag if it already exists on the page
36
-
37
- # 0.1.0
38
-
39
- - Initial version