jsf.js_next_gen 4.0.1-beta.1 → 4.0.1-beta.3
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.
- package/README.md +6 -0
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/functions/myfaces.ab.html +1 -1
- package/dist/docs/functions/{myfaces.onOnDomReady.html → myfaces.onDomReady.html} +5 -5
- package/dist/docs/index.html +9 -0
- package/dist/docs/modules/myfaces.html +2 -2
- package/dist/docs/variables/myfaces.oam.html +1 -1
- package/dist/window/faces-development.js +1285 -1295
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +1285 -1295
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +5 -5
- package/plans for 4.0.1.txt +8 -0
- package/src/main/typescript/api/_api.ts +1 -1
- package/src/main/typescript/impl/AjaxImpl.ts +60 -44
- package/src/main/typescript/impl/core/Const.ts +5 -2
- package/src/main/typescript/impl/util/AsyncRunnable.ts +81 -6
- package/src/main/typescript/impl/util/ExtDomQuery.ts +7 -9
- package/src/main/typescript/impl/util/FileUtils.ts +26 -22
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +7 -3
- package/src/main/typescript/impl/util/Lang.ts +61 -4
- package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
- package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +12 -10
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +32 -19
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +51 -72
- package/src/main/typescript/myfaces/OamSubmit.ts +6 -6
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +179 -40
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +921 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +3 -2
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
- package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
- package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
- package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +4 -4
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +2 -2
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +80 -6
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +6 -1
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +23 -22
- package/target/api/_api.js +2 -2
- package/target/api/_api.js.map +1 -1
- package/target/impl/AjaxImpl.js +48 -38
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +7 -5
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/util/AsyncRunnable.js +60 -0
- package/target/impl/util/AsyncRunnable.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +8 -8
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +21 -20
- package/target/impl/util/FileUtils.js.map +1 -1
- package/target/impl/util/HiddenInputBuilder.js +7 -3
- package/target/impl/util/HiddenInputBuilder.js.map +1 -1
- package/target/impl/util/Lang.js +52 -1
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +2 -2
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +9 -7
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +29 -15
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +43 -64
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +5 -3
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +138 -37
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +3 -2
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +26 -19
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +3 -3
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +73 -4
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +6 -0
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +22 -15
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
- package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
|
@@ -16,20 +16,21 @@
|
|
|
16
16
|
|
|
17
17
|
import {expect} from 'chai';
|
|
18
18
|
import {describe, it} from 'mocha';
|
|
19
|
-
import {ArrayCollector, DomQuery, DomQueryCollector, Lang, LazyStream} from "mona-dish";
|
|
20
|
-
import trim = Lang.trim;
|
|
21
19
|
import {from} from "rxjs";
|
|
22
|
-
|
|
20
|
+
import {ArrayCollector, Config, DomQuery, DomQueryCollector, Lang, LazyStream, Stream} from "mona-dish";
|
|
21
|
+
import {tobagoSheetWithHeader} from "./markups/tobago-with-header";
|
|
22
|
+
import {tobagoSheetWithoutHeader} from "./markups/tobago-without-header";
|
|
23
23
|
|
|
24
24
|
const jsdom = require("jsdom");
|
|
25
25
|
const {JSDOM} = jsdom;
|
|
26
|
+
import trim = Lang.trim;
|
|
27
|
+
|
|
26
28
|
(global as any).window = {}
|
|
27
29
|
let dom = null;
|
|
28
30
|
describe('DOMQuery tests', function () {
|
|
29
31
|
|
|
30
32
|
beforeEach(function () {
|
|
31
33
|
|
|
32
|
-
// language=HTML
|
|
33
34
|
dom = new JSDOM(`
|
|
34
35
|
<!DOCTYPE html>
|
|
35
36
|
<html lang="en">
|
|
@@ -86,14 +87,14 @@ describe('DOMQuery tests', function () {
|
|
|
86
87
|
let probe1 = new DomQuery(window.document.body);
|
|
87
88
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
88
89
|
|
|
89
|
-
let o1 = from(probe1
|
|
90
|
-
let o2 = from(probe2
|
|
90
|
+
let o1 = from(Stream.ofDataSource(probe1));
|
|
91
|
+
let o2 = from(Stream.ofDataSource(probe2));
|
|
91
92
|
|
|
92
93
|
let cnt1 = 0;
|
|
93
94
|
let isDQuery = false;
|
|
94
95
|
let cnt2 = 0;
|
|
95
96
|
|
|
96
|
-
o1.subscribe(() => {
|
|
97
|
+
o1.subscribe((item: any) => {
|
|
97
98
|
cnt1++;
|
|
98
99
|
});
|
|
99
100
|
|
|
@@ -112,14 +113,14 @@ describe('DOMQuery tests', function () {
|
|
|
112
113
|
let probe1 = new DomQuery(window.document.body);
|
|
113
114
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
114
115
|
|
|
115
|
-
let o1 = from(probe1
|
|
116
|
-
let o2 = from(probe2
|
|
116
|
+
let o1 = from(Stream.ofDataSource(probe1));
|
|
117
|
+
let o2 = from(Stream.ofDataSource(probe2));
|
|
117
118
|
|
|
118
119
|
let cnt1 = 0;
|
|
119
120
|
let isDQuery = false;
|
|
120
121
|
let cnt2 = 0;
|
|
121
122
|
|
|
122
|
-
o1.subscribe(() => {
|
|
123
|
+
o1.subscribe((item: any) => {
|
|
123
124
|
cnt1++;
|
|
124
125
|
});
|
|
125
126
|
|
|
@@ -183,7 +184,7 @@ describe('DOMQuery tests', function () {
|
|
|
183
184
|
it('domquery ops test2 eachNode', function () {
|
|
184
185
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
185
186
|
let noIter = 0;
|
|
186
|
-
probe2.each((item, cnt) => {
|
|
187
|
+
probe2 = probe2.each((item, cnt) => {
|
|
187
188
|
expect(item instanceof DomQuery).to.be.true;
|
|
188
189
|
expect(noIter == cnt).to.be.true;
|
|
189
190
|
noIter++;
|
|
@@ -298,28 +299,61 @@ describe('DOMQuery tests', function () {
|
|
|
298
299
|
expect(DomQuery.querySelectorAll("#insertedAfter2").isPresent()).to.be.true;
|
|
299
300
|
});
|
|
300
301
|
|
|
302
|
+
it('do not create new <html> tag on <header', function () {
|
|
303
|
+
|
|
304
|
+
const fromMarkupWithHeader = DomQuery.fromMarkup(tobagoSheetWithHeader);
|
|
305
|
+
const fromMarkupWithoutHeader = DomQuery.fromMarkup(tobagoSheetWithoutHeader);
|
|
306
|
+
|
|
307
|
+
expect(fromMarkupWithHeader.tagName.value === "HTML").to.be.false;
|
|
308
|
+
expect(fromMarkupWithoutHeader.tagName.value === "HTML").to.be.false;
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
it('do not falsely assume standard tag', function () {
|
|
313
|
+
|
|
314
|
+
const fromMarkup1 = DomQuery.fromMarkup(`
|
|
315
|
+
<head-mine>booga</head-mine>
|
|
316
|
+
`);
|
|
317
|
+
|
|
318
|
+
const fromMarkup2 = DomQuery.fromMarkup(`
|
|
319
|
+
<body_mine>booga</body_mine>
|
|
320
|
+
|
|
321
|
+
`);
|
|
322
|
+
expect(fromMarkup1.tagName.value === "HTML").to.be.false;
|
|
323
|
+
expect(fromMarkup1.tagName.value === "HTML").to.be.false;
|
|
324
|
+
expect(fromMarkup1.tagName.value === "HEAD").to.be.false;
|
|
325
|
+
expect(fromMarkup2.tagName.value === "BODY").to.be.false;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
|
|
301
329
|
it('it must stream', function () {
|
|
302
330
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
303
|
-
let coll: Array<any> = probe1.
|
|
331
|
+
let coll: Array<any> = Stream.ofDomQuery(probe1).collect(new ArrayCollector());
|
|
304
332
|
expect(coll.length == 4).to.be.true;
|
|
305
333
|
|
|
306
|
-
coll = probe1.
|
|
334
|
+
coll = LazyStream.ofDomQuery(probe1).collect(new ArrayCollector());
|
|
307
335
|
expect(coll.length == 4).to.be.true;
|
|
308
336
|
|
|
309
337
|
});
|
|
310
338
|
|
|
311
|
-
it('it must stream
|
|
339
|
+
it('it must stream - DQ API (dynamically added)', function () {
|
|
312
340
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
313
|
-
let coll:
|
|
341
|
+
let coll: Array<any> = probe1.asArray;
|
|
314
342
|
expect(coll.length == 4).to.be.true;
|
|
343
|
+
});
|
|
315
344
|
|
|
316
|
-
|
|
345
|
+
it('it must stream to a domquery', function () {
|
|
346
|
+
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
347
|
+
let coll: DomQuery = Stream.ofDataSource(probe1).collect(new DomQueryCollector());
|
|
348
|
+
expect(coll.length == 4).to.be.true;
|
|
349
|
+
probe1.reset();
|
|
350
|
+
coll = LazyStream.ofStreamDataSource(probe1).collect(new DomQueryCollector());
|
|
317
351
|
expect(coll.length == 4).to.be.true;
|
|
318
352
|
});
|
|
319
353
|
|
|
320
354
|
it('it must have parents', function () {
|
|
321
355
|
let probe1 = new DomQuery(document).querySelectorAll("div");
|
|
322
|
-
let coll: Array<any> = probe1.
|
|
356
|
+
let coll: Array<any> = Stream.ofDataSource(probe1.parentsWhileMatch("body")).collect(new ArrayCollector());
|
|
323
357
|
expect(coll.length == 1).to.be.true;
|
|
324
358
|
|
|
325
359
|
});
|
|
@@ -342,22 +376,90 @@ describe('DOMQuery tests', function () {
|
|
|
342
376
|
expect(innerHtml.indexOf("id_x_1_1") > innerHtml.indexOf("id_x_0_1")).to.be.true;
|
|
343
377
|
})
|
|
344
378
|
|
|
379
|
+
|
|
380
|
+
it("must have a working replace", function () {
|
|
381
|
+
let probe1 = new DomQuery(document).byId("id_1");
|
|
382
|
+
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
386
|
+
|
|
387
|
+
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
388
|
+
|
|
389
|
+
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
390
|
+
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_2")).to.be.true;
|
|
391
|
+
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_3")).to.be.true;
|
|
392
|
+
|
|
393
|
+
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
394
|
+
|
|
395
|
+
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
396
|
+
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_2")).to.be.true;
|
|
397
|
+
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_3")).to.be.true;
|
|
398
|
+
|
|
399
|
+
expect(innerHtml.indexOf("id_1") == -1).to.be.true;
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
it("must have a working replace - 2", function () {
|
|
403
|
+
let probe1 = new DomQuery(document).byId("id_2");
|
|
404
|
+
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
408
|
+
|
|
409
|
+
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
410
|
+
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_1")).to.be.true;
|
|
411
|
+
|
|
412
|
+
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
413
|
+
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_0")).to.be.true;
|
|
414
|
+
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_3")).to.be.true;
|
|
415
|
+
|
|
416
|
+
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
417
|
+
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_0")).to.be.true;
|
|
418
|
+
expect(innerHtml.indexOf("id_x_1") < innerHtml.indexOf("id_3")).to.be.true;
|
|
419
|
+
|
|
420
|
+
expect(innerHtml.indexOf("id_2") == -1).to.be.true;
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
it("must have a working replace - 3", function () {
|
|
424
|
+
let probe1 = new DomQuery(document).byId("id_4");
|
|
425
|
+
probe1.replace(DomQuery.fromMarkup(` <div id="id_x_0"></div><div id="id_x_1"></div>`));
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
expect(DomQuery.querySelectorAll("div").length).to.eq(5);
|
|
429
|
+
|
|
430
|
+
let innerHtml = DomQuery.querySelectorAll("body").innerHTML;
|
|
431
|
+
|
|
432
|
+
expect(innerHtml.indexOf("id_x_0") > 0).to.be.true;
|
|
433
|
+
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_1")).to.be.true;
|
|
434
|
+
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_2")).to.be.true;
|
|
435
|
+
expect(innerHtml.indexOf("id_x_0") > innerHtml.indexOf("id_3")).to.be.true;
|
|
436
|
+
|
|
437
|
+
expect(innerHtml.indexOf("id_x_0") < innerHtml.indexOf("id_x_1")).to.be.true;
|
|
438
|
+
|
|
439
|
+
expect(innerHtml.indexOf("id_x_1") > 0).to.be.true;
|
|
440
|
+
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_1")).to.be.true;
|
|
441
|
+
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_2")).to.be.true;
|
|
442
|
+
expect(innerHtml.indexOf("id_x_1") > innerHtml.indexOf("id_3")).to.be.true;
|
|
443
|
+
|
|
444
|
+
expect(innerHtml.indexOf("id_4") == -1).to.be.true;
|
|
445
|
+
})
|
|
446
|
+
|
|
345
447
|
it("must have a working input handling", function () {
|
|
346
448
|
DomQuery.querySelectorAll("body").innerHTML = `<form id="blarg">
|
|
347
449
|
<div id="embed1">
|
|
348
|
-
<input type="text" id="id_1" name="id_1" value="id_1_val">
|
|
349
|
-
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled">
|
|
350
|
-
<textarea id="id_3" name="id_3">textareaVal</textarea>
|
|
450
|
+
<input type="text" id="id_1" name="id_1" value="id_1_val"></input>
|
|
451
|
+
<input type="text" id="id_2" name="id_2" value="id_2_val" disabled="disabled"> </input>
|
|
452
|
+
<textarea type="text" id="id_3" name="id_3">textareaVal</textarea>
|
|
351
453
|
|
|
352
454
|
<fieldset>
|
|
353
|
-
<input type="radio" id="mc" name="cc_1" value="Mastercard" checked="checked">
|
|
455
|
+
<input type="radio" id="mc" name="cc_1" value="Mastercard" checked="checked"></input>
|
|
354
456
|
<label for="mc"> Mastercard</label>
|
|
355
|
-
<input type="radio" id="vi" name="cc_1" value="Visa">
|
|
457
|
+
<input type="radio" id="vi" name="cc_1" value="Visa"></input>
|
|
356
458
|
<label for="vi"> Visa</label>
|
|
357
|
-
<input type="radio" id="ae" name="cc_1" value="AmericanExpress">
|
|
459
|
+
<input type="radio" id="ae" name="cc_1" value="AmericanExpress"></input>
|
|
358
460
|
<label for="ae"> American Express</label>
|
|
359
461
|
</fieldset>
|
|
360
|
-
<select id="val_5" name="val_5" size="5">
|
|
462
|
+
<select id="val_5" name="val_5" name="top5" size="5">
|
|
361
463
|
<option>barg</option>
|
|
362
464
|
<option>jjj</option>
|
|
363
465
|
<option selected>akaka</option>
|
|
@@ -375,22 +477,22 @@ describe('DOMQuery tests', function () {
|
|
|
375
477
|
let length2 = DomQuery.byId("embed1").elements.length;
|
|
376
478
|
expect(length2 == 8).to.be.true;
|
|
377
479
|
|
|
378
|
-
let count = DomQuery.byId("embed1").elements
|
|
379
|
-
.
|
|
480
|
+
let count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
481
|
+
.map<number>(item => item.disabled ? 1 : 0)
|
|
380
482
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
381
483
|
expect(count.value).to.eq(1);
|
|
382
484
|
|
|
383
|
-
DomQuery.byId("embed1").elements
|
|
384
|
-
.
|
|
485
|
+
Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
486
|
+
.filter(item => item.disabled)
|
|
385
487
|
.each(item => item.disabled = false);
|
|
386
488
|
|
|
387
|
-
count = DomQuery.byId("embed1").elements
|
|
388
|
-
.
|
|
489
|
+
count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
490
|
+
.map<number>(item => item.disabled ? 1 : 0)
|
|
389
491
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
390
492
|
expect(count.value).to.eq(0);
|
|
391
493
|
|
|
392
|
-
count = DomQuery.byId("embed1").elements
|
|
393
|
-
.
|
|
494
|
+
count = Stream.ofDataSource(DomQuery.byId("embed1").elements)
|
|
495
|
+
.map<number>(item => item.attr("checked").isPresent() ? 1 : 0)
|
|
394
496
|
.reduce((val1, val2) => val1 + val2, 0);
|
|
395
497
|
expect(count.value).to.eq(1);
|
|
396
498
|
|
|
@@ -403,7 +505,7 @@ describe('DOMQuery tests', function () {
|
|
|
403
505
|
DomQuery.byId("id_3").inputValue.value = "hello world";
|
|
404
506
|
expect(DomQuery.byId("id_3").inputValue.value).to.eq("hello world");
|
|
405
507
|
|
|
406
|
-
let cfg = DomQuery.querySelectorAll("form").elements.encodeFormElement();
|
|
508
|
+
let cfg = new Config(DomQuery.querySelectorAll("form").elements.encodeFormElement());
|
|
407
509
|
expect(cfg.getIf("id_1").value[0]).to.eq("booga");
|
|
408
510
|
expect(cfg.getIf("id_2").value[0]).to.eq("id_2_val");
|
|
409
511
|
expect(cfg.getIf("id_3").value[0]).to.eq("hello world");
|
|
@@ -451,17 +553,22 @@ describe('DOMQuery tests', function () {
|
|
|
451
553
|
//-->
|
|
452
554
|
</script>
|
|
453
555
|
|
|
454
|
-
<style>
|
|
556
|
+
<style type="text/css">
|
|
455
557
|
#first {
|
|
456
558
|
border: 1px solid black;
|
|
457
559
|
}
|
|
458
560
|
</style>
|
|
561
|
+
|
|
562
|
+
<link rel="stylesheet" href="./fixtures/blank.css"></link>
|
|
459
563
|
`;
|
|
460
564
|
let content = DomQuery.byTagName("body").runScripts().runCss();
|
|
461
565
|
expect(content.byId("first").innerHTML).to.eq("hello world");
|
|
462
566
|
expect(content.byId("second").innerHTML).to.eq("hello world");
|
|
463
567
|
expect(content.byId("third").innerHTML).to.eq("hello world");
|
|
464
568
|
expect(content.byId("fourth").innerHTML).to.eq("hello world");
|
|
569
|
+
|
|
570
|
+
expect(DomQuery.byTagName("head")
|
|
571
|
+
.querySelectorAll("link[rel='stylesheet'][href='./fixtures/blank.css']").length).to.eq(1);
|
|
465
572
|
done();
|
|
466
573
|
|
|
467
574
|
});
|
|
@@ -482,7 +589,7 @@ describe('DOMQuery tests', function () {
|
|
|
482
589
|
|
|
483
590
|
it("it must handle events properly", function () {
|
|
484
591
|
let clicked = 0;
|
|
485
|
-
let listener = () => {
|
|
592
|
+
let listener = (evt: any) => {
|
|
486
593
|
clicked++;
|
|
487
594
|
};
|
|
488
595
|
let eventReceiver = DomQuery.byId("id_1");
|
|
@@ -498,7 +605,7 @@ describe('DOMQuery tests', function () {
|
|
|
498
605
|
|
|
499
606
|
});
|
|
500
607
|
|
|
501
|
-
it("it must handle innerText properly", function () {
|
|
608
|
+
it("it must handle innerText properly", function (done) {
|
|
502
609
|
|
|
503
610
|
//jsdom bug
|
|
504
611
|
Object.defineProperty(Object.prototype, 'innerText', {
|
|
@@ -510,6 +617,7 @@ describe('DOMQuery tests', function () {
|
|
|
510
617
|
let probe = DomQuery.byId("id_1");
|
|
511
618
|
probe.innerHTML = "<div>hello</div><div>world</div>";
|
|
512
619
|
expect(probe.innerText()).to.eq("helloworld");
|
|
620
|
+
done();
|
|
513
621
|
});
|
|
514
622
|
it("it must handle textContent properly", function () {
|
|
515
623
|
let probe = DomQuery.byId("id_1");
|
|
@@ -519,7 +627,7 @@ describe('DOMQuery tests', function () {
|
|
|
519
627
|
|
|
520
628
|
it("it must handle iterations properly", function () {
|
|
521
629
|
let probe = DomQuery.byTagName("div");
|
|
522
|
-
let resArr = probe.
|
|
630
|
+
let resArr = LazyStream.ofStreamDataSource(probe).collect(new ArrayCollector());
|
|
523
631
|
expect(resArr.length).to.eq(4);
|
|
524
632
|
|
|
525
633
|
probe.reset();
|
|
@@ -558,6 +666,21 @@ describe('DOMQuery tests', function () {
|
|
|
558
666
|
})
|
|
559
667
|
|
|
560
668
|
|
|
669
|
+
it("parent must break shadow barriers", function () {
|
|
670
|
+
let probe = DomQuery.fromMarkup("<div id='shadowItem'>hello</div>'");
|
|
671
|
+
try {
|
|
672
|
+
//probably not testable atm, mocha does not have shadow dom support
|
|
673
|
+
//we might be able to shim it in one way or the other
|
|
674
|
+
let element = DomQuery.byId("id_1").attachShadow();
|
|
675
|
+
element.append(probe);
|
|
676
|
+
expect(probe.firstParent("#id_1").length > 0).to.eq(true);
|
|
677
|
+
} catch (e) {
|
|
678
|
+
//not supported we still need to get an error here
|
|
679
|
+
expect(e.message.indexOf("not supported") != -1).to.be.true;
|
|
680
|
+
}
|
|
681
|
+
})
|
|
682
|
+
|
|
683
|
+
|
|
561
684
|
it('it must have a working wait for dom with mut observer and must detect condition after change', async function () {
|
|
562
685
|
let probe = DomQuery.byId('id_1');
|
|
563
686
|
probe.innerHTML = 'true';
|
|
@@ -629,11 +752,14 @@ describe('DOMQuery tests', function () {
|
|
|
629
752
|
|
|
630
753
|
it('must by recycleable', function () {
|
|
631
754
|
let probe = DomQuery.querySelectorAll("div");
|
|
755
|
+
let probe2 = DomQuery.querySelectorAll("body");
|
|
632
756
|
|
|
633
757
|
let res1 = probe.filter(item => item.matchesSelector("div"));
|
|
634
758
|
expect(res1.length).to.eq(4);
|
|
635
759
|
let res2 = probe.filter(item => item.matchesSelector("div"));
|
|
636
760
|
expect(res2.length).to.eq(4);
|
|
761
|
+
|
|
762
|
+
|
|
637
763
|
})
|
|
638
764
|
|
|
639
765
|
it('delete must work', function () {
|
|
@@ -651,9 +777,22 @@ describe('DOMQuery tests', function () {
|
|
|
651
777
|
let probe2 = DomQuery.querySelectorAll("div");
|
|
652
778
|
let probeCnt = 0;
|
|
653
779
|
let probe2Cnt = 0;
|
|
654
|
-
from(probe).subscribe(
|
|
655
|
-
from(probe2
|
|
780
|
+
from(probe).subscribe(el => probeCnt++);
|
|
781
|
+
from(Stream.ofDataSource(probe2)).subscribe(el => probe2Cnt++);
|
|
656
782
|
expect(probeCnt).to.be.above(0);
|
|
657
783
|
expect(probeCnt).to.eq(probe2Cnt);
|
|
658
|
-
})
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
it('must handle closest properly', function() {
|
|
787
|
+
let probe = DomQuery.byId("id_1");
|
|
788
|
+
probe.innerHTML = "<div id='inner_elem'>hello world<div id='inner_elem2'></div></div>";
|
|
789
|
+
|
|
790
|
+
let probe2 = DomQuery.byId("inner_elem");
|
|
791
|
+
expect(probe2.closest("div#id_1").id.value).to.eq("id_1");
|
|
792
|
+
expect(probe2.parent().closest("div").id.value).to.eq("id_1");
|
|
793
|
+
probe2 = DomQuery.byId("inner_elem2");
|
|
794
|
+
expect(probe2.closest("div").id.value).to.eq("inner_elem2");
|
|
795
|
+
expect(probe2.closest("div#id_1").id.value).to.eq("id_1");
|
|
796
|
+
expect(probe2.parent().parent().closest("div").id.value).to.eq("id_1");
|
|
797
|
+
});
|
|
659
798
|
});
|
|
@@ -125,7 +125,7 @@ describe('Config tests', () => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it('array config2', () => {
|
|
128
|
-
let config =
|
|
128
|
+
let config = new Config([]);
|
|
129
129
|
config.assign("[5]", "world[3]", "from").value = "me";
|
|
130
130
|
expect(config.getIf("[5]", "world[3]", "from").value).to.be.eq("me");
|
|
131
131
|
expect(config.value[5].world[3].from).to.be.eq("me");
|
|
@@ -133,7 +133,7 @@ describe('Config tests', () => {
|
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
it('array config3', () => {
|
|
136
|
-
let config =
|
|
136
|
+
let config = new Config([]);
|
|
137
137
|
config.assign("[5]", "[3]", "from").value = "me";
|
|
138
138
|
expect(config.getIf("[5]", "[3]", "from").value).to.be.eq("me");
|
|
139
139
|
expect(config.value[5][3].from).to.be.eq("me");
|
|
@@ -141,7 +141,7 @@ describe('Config tests', () => {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
it('array config4', () => {
|
|
144
|
-
let config =
|
|
144
|
+
let config = new Config([]);
|
|
145
145
|
config.assign("[5]", "[3]", "[2]").value = "me";
|
|
146
146
|
expect(config.getIf("[5]", "[3]", "[2]").value).to.be.eq("me");
|
|
147
147
|
expect(config.value[5][3][2]).to.be.eq("me");
|
|
@@ -149,7 +149,7 @@ describe('Config tests', () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
it('array config5', () => {
|
|
152
|
-
let config =
|
|
152
|
+
let config = new Config([]);
|
|
153
153
|
config.assign("[5]", "world[3]", "from[2]").value = "me";
|
|
154
154
|
expect(config.getIf("[5]", "world[3]", "from[2]").value).to.be.eq("me");
|
|
155
155
|
expect(config.value[5].world[3].from[2]).to.be.eq("me");
|
|
File without changes
|