powerpagestoolkit 2.6.3327 → 2.6.33311

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.
@@ -187,7 +187,7 @@ export default class DOMNodeReference {
187
187
  remove(): this;
188
188
  /**
189
189
  *
190
- * @param {Partial<CSSStyleDeclaration} options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
190
+ * @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
191
191
  * @returns - Instance of this [provides option to method chain]
192
192
  */
193
193
  setStyle(options: Partial<CSSStyleDeclaration>): this;
package/dist/bundle.js CHANGED
@@ -481,7 +481,8 @@ var DOMNodeReference = class _DOMNodeReference {
481
481
  this.noRadio = await createDOMNodeReference(`#${this.element.id}_0`);
482
482
  }
483
483
  [_bindMethods]() {
484
- for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(this))) {
484
+ const prototype = Object.getPrototypeOf(this);
485
+ for (const key of Object.getOwnPropertyNames(prototype)) {
485
486
  const value = this[key];
486
487
  if (key !== "constructor" && typeof value === "function") {
487
488
  this[key] = value.bind(this);
@@ -579,7 +580,7 @@ var DOMNodeReference = class _DOMNodeReference {
579
580
  if (value instanceof Function) {
580
581
  value = value();
581
582
  }
582
- if (this.element.classList.contains("boolean-radio")) {
583
+ if (this.element.classList.contains("boolean-radio") && this.yesRadio instanceof _DOMNodeReference && this.noRadio instanceof _DOMNodeReference) {
583
584
  this.yesRadio.element.checked = value;
584
585
  this.noRadio.element.checked = !value;
585
586
  } else {
@@ -770,7 +771,7 @@ var DOMNodeReference = class _DOMNodeReference {
770
771
  }
771
772
  /**
772
773
  *
773
- * @param {Partial<CSSStyleDeclaration} options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
774
+ * @param options and object containing the styles you want to set : {key: value} e.g.: {'display': 'block'}
774
775
  * @returns - Instance of this [provides option to method chain]
775
776
  */
776
777
  setStyle(options) {
@@ -779,7 +780,8 @@ var DOMNodeReference = class _DOMNodeReference {
779
780
  `powerpagestoolkit: 'DOMNodeReference.setStyle' required options to be in the form of an object. Argument passed was of type: ${typeof options}`
780
781
  );
781
782
  }
782
- for (const key in options) {
783
+ for (const _key in options) {
784
+ const key = _key;
783
785
  this.element.style[key] = options[key];
784
786
  }
785
787
  return this;
@@ -1034,22 +1036,8 @@ async function createDOMNodeReference(target, options = {
1034
1036
  `'options' must be of type 'object'. Received type: '${typeof options}'`
1035
1037
  );
1036
1038
  }
1039
+ validateOptions(options);
1037
1040
  const { multiple = false, root = document.body, timeout = 0 } = options;
1038
- if (typeof multiple !== "boolean" && typeof multiple !== "function") {
1039
- throw new Error(
1040
- `'multiple' must be of type 'boolean' or 'function'. Received type: '${typeof multiple}'`
1041
- );
1042
- }
1043
- if (!(root instanceof HTMLElement)) {
1044
- throw new Error(
1045
- `'root' must be of type 'HTMLElement'. Received type: '${typeof root}'`
1046
- );
1047
- }
1048
- if (typeof timeout !== "number") {
1049
- throw new Error(
1050
- `'timeout' must be of type 'number'. Received type: '${typeof timeout}'`
1051
- );
1052
- }
1053
1041
  const isMultiple = typeof multiple === "function" ? multiple() : multiple;
1054
1042
  if (isMultiple) {
1055
1043
  if (typeof target !== "string") {
@@ -1074,6 +1062,33 @@ async function createDOMNodeReference(target, options = {
1074
1062
  throw new Error(e);
1075
1063
  }
1076
1064
  }
1065
+ function validateOptions(options) {
1066
+ const { multiple = false, root = document.body, timeout = 0 } = options;
1067
+ if (typeof multiple !== "boolean" && typeof multiple !== "function") {
1068
+ throw new Error(
1069
+ `'multiple' must be of type 'boolean' or 'function'. Received type: '${typeof multiple}'`
1070
+ );
1071
+ }
1072
+ if (typeof multiple === "function") {
1073
+ const value = multiple();
1074
+ if (typeof value !== "boolean") {
1075
+ throw new Error(
1076
+ `'multiple' function must return a boolean. Received type: '${typeof value}'`
1077
+ );
1078
+ }
1079
+ }
1080
+ if (!(root instanceof HTMLElement)) {
1081
+ throw new Error(
1082
+ `'root' must be of type 'HTMLElement'. Received type: '${typeof root}'`
1083
+ );
1084
+ }
1085
+ if (typeof timeout !== "number") {
1086
+ throw new Error(
1087
+ `'timeout' must be of type 'number'. Received type: '${typeof timeout}'`
1088
+ );
1089
+ }
1090
+ return;
1091
+ }
1077
1092
  function createProxyHandler() {
1078
1093
  return {
1079
1094
  get: (target, prop) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerpagestoolkit",
3
- "version": "2.6.3327",
3
+ "version": "2.6.33311",
4
4
  "description": "Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier. ",
5
5
  "main": "./dist/bundle.js",
6
6
  "types": "./dist/index.d.ts",