Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions lib/asset-js.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@


import { uriIsRelative, pathnameBuilder } from './utils.js';
import { buildScriptElement, buildReactScriptAttributes } from './html-utils.js';
import {
buildScriptElement,
buildReactScriptAttributes,
} from './html-utils.js';

const inspect = Symbol.for('nodejs.util.inspect.custom');

Expand Down Expand Up @@ -29,6 +30,23 @@ export default class PodiumAssetJs {
#data;
#strategy;
#scope;

/**
* @param {object} options
* @param {string} [options.referrerpolicy]
* @param {string} [options.crossorigin]
* @param {string} [options.integrity]
* @param {string} [options.pathname]
* @param {boolean} [options.nomodule=false]
* @param {boolean} [options.prefix=false]
* @param {string} [options.value]
* @param {boolean} [options.async=false]
* @param {boolean} [options.defer=false]
* @param {string} [options.type="default"]
* @param {array} [options.data]
* @param {string} [options.strategy]
* @param {string} [options.scope]
*/
constructor({
referrerpolicy = '',
crossorigin = undefined,
Expand All @@ -44,11 +62,12 @@ export default class PodiumAssetJs {
strategy = undefined,
scope = undefined,
} = {}) {
if (!toUndefined(value))
if (!toUndefined(value)) {
throw new Error(
`Value for argument variable "value", "${value}", is not valid`,
);

}

this.#pathname = pathname;
this.#prefix = prefix;
this.#value = value;
Expand All @@ -57,8 +76,15 @@ export default class PodiumAssetJs {
this.#crossorigin = crossorigin;
this.#integrity = integrity;
this.#nomodule = nomodule;
this.#async = async;
this.#defer = defer;

if (async && defer) {
this.#async = false;
this.#defer = true;
} else {
this.#async = async;
this.#defer = defer;
}

this.#type = type;
this.#data = data;
this.#strategy = strategy;
Expand Down Expand Up @@ -148,15 +174,15 @@ export default class PodiumAssetJs {
}

get strategy() {
return this.#strategy;
return this.#strategy;
}

set strategy(value) {
this.#strategy = value;
}

get scope() {
return this.#scope;
return this.#scope;
}

set scope(value) {
Expand Down Expand Up @@ -204,4 +230,4 @@ export default class PodiumAssetJs {
get [Symbol.toStringTag]() {
return 'PodiumAssetJs';
}
};
}
Loading