jsf.js_next_gen 4.0.0-beta-21 → 4.0.0-beta-22

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.
Files changed (35) hide show
  1. package/dist/window/faces-development.js +49 -27
  2. package/dist/window/faces-development.js.br +0 -0
  3. package/dist/window/faces-development.js.gz +0 -0
  4. package/dist/window/faces-development.js.map +1 -1
  5. package/dist/window/faces.js +1 -1
  6. package/dist/window/faces.js.br +0 -0
  7. package/dist/window/faces.js.gz +0 -0
  8. package/dist/window/faces.js.map +1 -1
  9. package/dist/window/jsf-development.js +49 -27
  10. package/dist/window/jsf-development.js.br +0 -0
  11. package/dist/window/jsf-development.js.gz +0 -0
  12. package/dist/window/jsf-development.js.map +1 -1
  13. package/dist/window/jsf.js +1 -1
  14. package/dist/window/jsf.js.br +0 -0
  15. package/dist/window/jsf.js.gz +0 -0
  16. package/dist/window/jsf.js.map +1 -1
  17. package/package.json +2 -2
  18. package/src/main/typescript/impl/util/ExtDomQuery.ts +5 -7
  19. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +2 -1
  20. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +6 -0
  21. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +4 -3
  22. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +15 -0
  23. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +15 -0
  24. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +15 -0
  25. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +15 -2
  26. package/src/main/typescript/test/xhrCore/fixtures/nonce_script.js +16 -0
  27. package/src/tmp/test.html +92 -0
  28. package/target/impl/util/ExtDomQuery.js +3 -2
  29. package/target/impl/util/ExtDomQuery.js.map +1 -1
  30. package/target/test/frameworkBase/_ext/shared/StandardInits.js +2 -1
  31. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  32. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +5 -0
  33. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  34. package/target/test/xhrCore/ResponseTest.spec.js +0 -2
  35. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
@@ -1035,19 +1035,8 @@ class DomQuery {
1035
1035
  * @param defer in miliseconds execution default (0 == no defer)
1036
1036
  * @param charSet
1037
1037
  */
1038
- loadScriptEval(src, defer = 0, charSet = "utf-8", nonce) {
1039
- let srcNode = this.createSourceNode(src, nonce);
1040
- let head = document.head;
1041
- if (!defer) {
1042
- head.appendChild(srcNode);
1043
- head.removeChild(srcNode);
1044
- }
1045
- else {
1046
- setTimeout(() => {
1047
- head.appendChild(srcNode);
1048
- head.removeChild(srcNode);
1049
- }, defer);
1050
- }
1038
+ loadScriptEval(src, defer = 0, nonce) {
1039
+ this._loadScriptEval(false, src, defer, nonce);
1051
1040
  return this;
1052
1041
  }
1053
1042
  /**
@@ -1057,15 +1046,45 @@ class DomQuery {
1057
1046
  * @param defer in miliseconds execution default (0 == no defer)
1058
1047
  * @param charSet
1059
1048
  */
1060
- loadScriptEvalSticky(src, defer = 0, charSet = "utf-8", nonce) {
1049
+ loadScriptEvalSticky(src, defer = 0, nonce) {
1050
+ this._loadScriptEval(true, src, defer, nonce);
1051
+ return this;
1052
+ }
1053
+ _loadScriptEval(sticky, src, defer = 0, nonce) {
1061
1054
  let srcNode = this.createSourceNode(src, nonce);
1062
- if (!defer) {
1063
- document.head.appendChild(srcNode);
1055
+ let nonceCheck = this.createSourceNode(null, nonce);
1056
+ let marker = `nonce_${Date.now()}_${Math.random()}`;
1057
+ nonceCheck.innerHTML = `document.head["${marker}"] = true`; //noop
1058
+ let head = document.head;
1059
+ // upfront nonce check, needed mostly for testing
1060
+ // but cannot hurt to block src calls which have invalid nonce on localhost
1061
+ // the reason for doing this up until now we have a similar construct automatically
1062
+ // by loading the scripts via xhr and then embedding them.
1063
+ // this is not needed anymore but the nonce is more relaxed with script src
1064
+ // we now enforce it the old way
1065
+ head.appendChild(nonceCheck);
1066
+ head.removeChild(nonceCheck);
1067
+ if (!head[marker]) {
1068
+ return;
1064
1069
  }
1065
- else {
1066
- setTimeout(() => {
1067
- document.head.appendChild(srcNode);
1068
- }, defer);
1070
+ try {
1071
+ if (!defer) {
1072
+ head.appendChild(srcNode);
1073
+ if (!sticky) {
1074
+ head.removeChild(srcNode);
1075
+ }
1076
+ }
1077
+ else {
1078
+ setTimeout(() => {
1079
+ head.appendChild(srcNode);
1080
+ if (!sticky) {
1081
+ head.removeChild(srcNode);
1082
+ }
1083
+ }, defer);
1084
+ }
1085
+ }
1086
+ finally {
1087
+ delete head[marker];
1069
1088
  }
1070
1089
  return this;
1071
1090
  }
@@ -1284,14 +1303,14 @@ class DomQuery {
1284
1303
  //we run the collected scripts before running, the include
1285
1304
  finalScripts = evalCollectedScripts(finalScripts);
1286
1305
  if (!sticky) {
1287
- (!!nonce) ? this.loadScriptEval(src, 0, "UTF-8", nonce) :
1306
+ (!!nonce) ? this.loadScriptEval(src, 0, nonce) :
1288
1307
  //if no nonce is set we do not pass any once
1289
- this.loadScriptEval(src, 0, "UTF-8");
1308
+ this.loadScriptEval(src, 0);
1290
1309
  }
1291
1310
  else {
1292
- (!!nonce) ? this.loadScriptEvalSticky(src, 0, "UTF-8", nonce) :
1311
+ (!!nonce) ? this.loadScriptEvalSticky(src, 0, nonce) :
1293
1312
  //if no nonce is set we do not pass any once
1294
- this.loadScriptEvalSticky(src, 0, "UTF-8");
1313
+ this.loadScriptEvalSticky(src, 0);
1295
1314
  }
1296
1315
  }
1297
1316
  }
@@ -1802,7 +1821,9 @@ class DomQuery {
1802
1821
  srcNode.setAttribute("nonce", nonce);
1803
1822
  }
1804
1823
  }
1805
- srcNode.src = src;
1824
+ if (!!src) {
1825
+ srcNode.src = src;
1826
+ }
1806
1827
  return srcNode;
1807
1828
  }
1808
1829
  }
@@ -5404,7 +5425,7 @@ const IS_FACES_SOURCE = (source) => {
5404
5425
  };
5405
5426
  /**
5406
5427
  * namespace myfaces.testscripts can be used as extension point for internal
5407
- * tests, those will be handled similarly to faces.js regarding
5428
+ * tests, those will be handled similarly to faces.js - regarding
5408
5429
  * reload blocking on ajax requests
5409
5430
  *
5410
5431
  * @param source the source to check
@@ -5514,6 +5535,7 @@ class ExtDomquery extends mona_dish_1.DQ {
5514
5535
  /**
5515
5536
  * decorated run scripts which takes our jsf extensions into consideration
5516
5537
  * (standard DomQuery will let you pass anything)
5538
+ * @param sticky if set to true the internally generated element for the script is left in the dom
5517
5539
  * @param whilteListed
5518
5540
  */
5519
5541
  runScripts(sticky = false, whilteListed) {
@@ -5526,7 +5548,7 @@ class ExtDomquery extends mona_dish_1.DQ {
5526
5548
  /**
5527
5549
  * adds the elements in this ExtDomQuery to the head
5528
5550
  *
5529
- * @param newElements the elements which need addition
5551
+ * @param suppressDoubleIncludes checks for existing elements in the head before running the insert
5530
5552
  */
5531
5553
  runHeadInserts(suppressDoubleIncludes = true) {
5532
5554
  let head = ExtDomquery.byId(document.head);
Binary file
Binary file