jsf.js_next_gen 4.0.1-beta.8 → 4.0.1-beta.9

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.
@@ -580,6 +580,34 @@ var isString = Lang_1.Lang.isString;
580
580
  var eqi = Lang_1.Lang.equalsIgnoreCase;
581
581
  var objToArray = Lang_1.Lang.objToArray;
582
582
  const AssocArray_1 = __webpack_require__(/*! ./AssocArray */ "./node_modules/mona-dish/src/main/typescript/AssocArray.ts");
583
+ class NonceValueEmbedder extends Monad_1.ValueEmbedder {
584
+ constructor(rootElems) {
585
+ super(rootElems === null || rootElems === void 0 ? void 0 : rootElems[0], "nonce");
586
+ this.rootElems = rootElems;
587
+ }
588
+ isAbsent() {
589
+ const value = this.value;
590
+ return 'undefined' == typeof value || '' == value;
591
+ }
592
+ get value() {
593
+ var _a, _b, _c, _d, _e;
594
+ return (_c = (_b = (_a = this === null || this === void 0 ? void 0 : this.rootElems) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.nonce) !== null && _c !== void 0 ? _c : (_e = (_d = this === null || this === void 0 ? void 0 : this.rootElems) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.getAttribute("nonce");
595
+ }
596
+ set value(newVal) {
597
+ var _a;
598
+ if (!((_a = this === null || this === void 0 ? void 0 : this.rootElems) === null || _a === void 0 ? void 0 : _a.length)) {
599
+ return;
600
+ }
601
+ this.rootElems.forEach((rootElem) => {
602
+ if ("undefined" != typeof (rootElem === null || rootElem === void 0 ? void 0 : rootElem.nonce)) {
603
+ rootElem.nonce = newVal;
604
+ }
605
+ else {
606
+ rootElem.setAttribute("nonce", newVal);
607
+ }
608
+ });
609
+ }
610
+ }
583
611
  /**
584
612
  *
585
613
  * // - submit checkboxes and radio inputs only if checked
@@ -983,8 +1011,7 @@ class DomQuery {
983
1011
  return new Es2019Array_1.Es2019Array(...this.rootNode.filter(item => item != null));
984
1012
  }
985
1013
  get nonce() {
986
- var _a, _b, _c, _d, _e;
987
- return Monad_1.Optional.fromNullable((_c = (_b = (_a = this === null || this === void 0 ? void 0 : this.rootNode) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.nonce) !== null && _c !== void 0 ? _c : (_e = (_d = this === null || this === void 0 ? void 0 : this.rootNode) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.getAttribute("nonce"));
1014
+ return new NonceValueEmbedder(this.rootNode);
988
1015
  }
989
1016
  static querySelectorAllDeep(selector) {
990
1017
  return new DomQuery(document).querySelectorAllDeep(selector);
@@ -1678,11 +1705,18 @@ class DomQuery {
1678
1705
  case "checked":
1679
1706
  this.resolveAttributeHolder("checked").checked = value;
1680
1707
  break;
1708
+ case "nonce":
1709
+ // nonce will be handled below!
1710
+ break;
1681
1711
  default:
1682
1712
  this.attr(name).value = value;
1683
1713
  }
1684
1714
  }
1685
1715
  });
1716
+ //special nonce handling
1717
+ sourceItem.nonce.isPresent(() => {
1718
+ this.nonce.value = sourceItem.nonce.value;
1719
+ });
1686
1720
  return this;
1687
1721
  }
1688
1722
  /**
@@ -5815,19 +5849,19 @@ class ExtDomQuery extends mona_dish_1.DQ {
5815
5849
  * this is done once and only lazily
5816
5850
  */
5817
5851
  get nonce() {
5818
- var _a, _b, _c;
5852
+ var _a;
5819
5853
  //already processed
5820
5854
  let myfacesConfig = new ExtConfig(window.myfaces);
5821
5855
  let globalNonce = myfacesConfig.getIf("config", "cspMeta", "nonce");
5822
5856
  if (!!globalNonce.value) {
5823
- return mona_dish_1.Optional.fromNullable(globalNonce.value);
5857
+ return mona_dish_1.ValueEmbedder.fromNullable(globalNonce);
5824
5858
  }
5825
5859
  let curScript = new mona_dish_1.DQ(document.currentScript);
5826
5860
  //since our baseline atm is ie11 we cannot use document.currentScript globally
5827
5861
  let nonce = curScript.nonce;
5828
5862
  if (nonce.isPresent()) {
5829
5863
  // fast-path for modern browsers
5830
- return nonce;
5864
+ return mona_dish_1.ValueEmbedder.fromNullable(nonce);
5831
5865
  }
5832
5866
  // fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
5833
5867
  // the last possibility
@@ -5835,7 +5869,10 @@ class ExtDomQuery extends mona_dish_1.DQ {
5835
5869
  .querySelectorAll("script[src], link[src]").asArray
5836
5870
  .filter((item) => item.nonce.isPresent() && item.attr(ATTR_SRC) != null)
5837
5871
  .filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))) === null || _a === void 0 ? void 0 : _a[0]);
5838
- return mona_dish_1.Optional.fromNullable((_c = (_b = nonceScript.value) === null || _b === void 0 ? void 0 : _b.nonce) === null || _c === void 0 ? void 0 : _c.value);
5872
+ if (!(nonceScript === null || nonceScript === void 0 ? void 0 : nonceScript.value)) {
5873
+ return mona_dish_1.ValueEmbedder.absent;
5874
+ }
5875
+ return new mona_dish_1.DomQuery(nonceScript.value).nonce;
5839
5876
  }
5840
5877
  static searchJsfJsFor(item) {
5841
5878
  return new ExtDomQuery(document).searchJsfJsFor(item);
Binary file
Binary file