@schukai/monster 1.13.0 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +46 -1
- package/README.md +5 -5
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +2 -2
- package/dist/modules/constraints/abstractoperator.js +2 -2
- package/dist/modules/constraints/andoperator.js +2 -2
- package/dist/modules/constraints/invalid.js +2 -2
- package/dist/modules/constraints/isarray.js +2 -2
- package/dist/modules/constraints/isobject.js +2 -2
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +2 -2
- package/dist/modules/constraints/valid.js +2 -2
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +2 -2
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +2 -2
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +2 -2
- package/dist/modules/dom/attributes.js +2 -2
- package/dist/modules/dom/constants.js +2 -2
- package/dist/modules/dom/customcontrol.js +2 -0
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +2 -2
- package/dist/modules/dom/locale.js +2 -2
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/template.js +2 -2
- package/dist/modules/dom/theme.js +2 -2
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +2 -2
- package/dist/modules/i18n/locale.js +2 -2
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +2 -2
- package/dist/modules/i18n/providers/fetch.js +2 -2
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +2 -2
- package/dist/modules/logging/handler/console.js +2 -2
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +2 -2
- package/dist/modules/logging/logentry.js +2 -2
- package/dist/modules/logging/logger.js +2 -2
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +2 -2
- package/dist/modules/namespace.js +2 -2
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +2 -2
- package/dist/modules/types/basewithoptions.js +2 -2
- package/dist/modules/types/global.js +2 -2
- package/dist/modules/types/id.js +2 -2
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/observer.js +2 -2
- package/dist/modules/types/observerlist.js +2 -2
- package/dist/modules/types/proxyobserver.js +2 -2
- package/dist/modules/types/queue.js +2 -2
- package/dist/modules/types/randomid.js +2 -2
- package/dist/modules/types/stack.js +2 -2
- package/dist/modules/types/tokenlist.js +2 -2
- package/dist/modules/types/typeof.js +2 -2
- package/dist/modules/types/uniquequeue.js +2 -2
- package/dist/modules/types/validate.js +2 -2
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +2 -2
- package/dist/modules/util/comparator.js +2 -2
- package/dist/modules/util/freeze.js +2 -2
- package/dist/modules/util/namespace.js +1 -1
- package/dist/monster.dev.js +8622 -7709
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -9
- package/package.json +1 -1
- package/source/constants.js +7 -6
- package/source/constraints/abstract.js +2 -2
- package/source/constraints/abstractoperator.js +4 -4
- package/source/constraints/andoperator.js +8 -8
- package/source/constraints/invalid.js +6 -6
- package/source/constraints/isarray.js +7 -7
- package/source/constraints/isobject.js +7 -7
- package/source/constraints/namespace.js +2 -2
- package/source/constraints/oroperator.js +8 -8
- package/source/constraints/valid.js +7 -7
- package/source/data/buildmap.js +15 -15
- package/source/data/diff.js +9 -9
- package/source/data/extend.js +55 -13
- package/source/data/namespace.js +2 -2
- package/source/data/pathfinder.js +13 -14
- package/source/data/pipe.js +8 -8
- package/source/data/transformer.js +11 -11
- package/source/dom/assembler.js +7 -7
- package/source/dom/attributes.js +89 -46
- package/source/dom/constants.js +9 -2
- package/source/dom/customcontrol.js +299 -0
- package/source/dom/customelement.js +181 -66
- package/source/dom/events.js +58 -8
- package/source/dom/locale.js +5 -5
- package/source/dom/namespace.js +2 -2
- package/source/dom/template.js +24 -19
- package/source/dom/theme.js +8 -9
- package/source/dom/updater.js +46 -24
- package/source/dom/util.js +10 -10
- package/source/i18n/locale.js +7 -7
- package/source/i18n/namespace.js +1 -1
- package/source/i18n/provider.js +6 -6
- package/source/i18n/providers/fetch.js +10 -10
- package/source/i18n/translations.js +5 -5
- package/source/logging/handler/console.js +5 -5
- package/source/logging/handler/namespace.js +1 -1
- package/source/logging/handler.js +8 -8
- package/source/logging/logentry.js +5 -5
- package/source/logging/logger.js +5 -5
- package/source/logging/namespace.js +2 -2
- package/source/math/namespace.js +2 -2
- package/source/math/random.js +5 -5
- package/source/monster.js +48 -44
- package/source/namespace.js +2 -2
- package/source/text/formatter.js +6 -7
- package/source/text/namespace.js +1 -1
- package/source/types/base.js +4 -5
- package/source/types/basewithoptions.js +10 -9
- package/source/types/global.js +7 -7
- package/source/types/id.js +7 -7
- package/source/types/is.js +22 -22
- package/source/types/namespace.js +2 -2
- package/source/types/observer.js +7 -7
- package/source/types/observerlist.js +4 -4
- package/source/types/proxyobserver.js +32 -26
- package/source/types/queue.js +13 -7
- package/source/types/randomid.js +6 -6
- package/source/types/stack.js +11 -4
- package/source/types/tokenlist.js +9 -9
- package/source/types/typeof.js +5 -5
- package/source/types/uniquequeue.js +14 -7
- package/source/types/validate.js +27 -27
- package/source/types/version.js +9 -9
- package/source/util/clone.js +6 -6
- package/source/util/comparator.js +7 -7
- package/source/util/freeze.js +7 -7
- package/source/util/namespace.js +2 -2
- package/test/cases/data/extend.js +66 -13
- package/test/cases/dom/attributes.js +56 -1
- package/test/cases/dom/customcontrol.js +264 -0
- package/test/cases/dom/customelement.js +112 -51
- package/test/cases/dom/events.js +32 -14
- package/test/cases/dom/template.js +40 -1
- package/test/cases/monster.js +1 -1
- package/test/cases/types/proxyobserver.js +9 -0
- package/test/util/jsdom.js +3 -0
- package/test/web/import.js +1 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +3 -3
package/test/cases/dom/events.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import {expect} from "chai"
|
4
4
|
|
5
|
-
import {fireEvent} from "../../../source/dom/events.js";
|
5
|
+
import {fireEvent, findTargetElementFromEvent} from "../../../source/dom/events.js";
|
6
6
|
import {initJSDOM} from "../../util/jsdom.js";
|
7
7
|
|
8
8
|
describe('Events', function () {
|
@@ -11,6 +11,24 @@ describe('Events', function () {
|
|
11
11
|
initJSDOM();
|
12
12
|
})
|
13
13
|
|
14
|
+
describe('findTargetElementFromEvent()', function () {
|
15
|
+
|
16
|
+
it('find object', function (done) {
|
17
|
+
let container = document.createElement('div');
|
18
|
+
container.setAttribute('data-monster', 'hello');
|
19
|
+
let div = document.createElement('div');
|
20
|
+
container.appendChild(div);
|
21
|
+
div.addEventListener('click', (event) => {
|
22
|
+
|
23
|
+
let e = findTargetElementFromEvent(event, 'data-monster');
|
24
|
+
expect(e.getAttribute('data-monster')).to.be.equal('hello')
|
25
|
+
done();
|
26
|
+
})
|
27
|
+
fireEvent(div, 'click');
|
28
|
+
});
|
29
|
+
|
30
|
+
});
|
31
|
+
|
14
32
|
describe('fireEvent()', function () {
|
15
33
|
it('should fire a click event', function (done) {
|
16
34
|
let div = document.createElement('div');
|
@@ -19,7 +37,7 @@ describe('Events', function () {
|
|
19
37
|
})
|
20
38
|
fireEvent(div, 'click');
|
21
39
|
});
|
22
|
-
|
40
|
+
|
23
41
|
it('should fire a touch event', function (done) {
|
24
42
|
let div = document.createElement('div');
|
25
43
|
div.addEventListener('touch', () => {
|
@@ -27,36 +45,36 @@ describe('Events', function () {
|
|
27
45
|
})
|
28
46
|
fireEvent(div, 'touch');
|
29
47
|
});
|
30
|
-
|
48
|
+
|
31
49
|
it('should fire a touch event on collection', function (done) {
|
32
50
|
let div = document.createElement('div');
|
33
51
|
div.addEventListener('touch', () => {
|
34
52
|
done();
|
35
53
|
})
|
36
|
-
|
54
|
+
|
37
55
|
div.appendChild(document.createElement('div'));
|
38
56
|
let collection = div.querySelectorAll('div');
|
39
|
-
|
40
|
-
|
57
|
+
|
58
|
+
|
41
59
|
fireEvent(collection, 'touch');
|
42
60
|
});
|
43
|
-
|
61
|
+
|
44
62
|
it('should fire a touch event', function (done) {
|
45
63
|
let div = document.createElement('div');
|
46
64
|
div.addEventListener('touch', () => {
|
47
65
|
done();
|
48
66
|
})
|
49
|
-
|
67
|
+
|
50
68
|
div.appendChild(document.createElement('div'));
|
51
69
|
let collection = div.querySelectorAll('div');
|
52
|
-
|
53
|
-
|
70
|
+
|
71
|
+
|
54
72
|
fireEvent(collection, 'touch');
|
55
|
-
});
|
56
|
-
|
73
|
+
});
|
74
|
+
|
57
75
|
it('should throw error', function () {
|
58
|
-
expect(() =>
|
59
|
-
|
76
|
+
expect(() => fireEvent({}, 'touch')).to.throw(Error);
|
77
|
+
;
|
60
78
|
});
|
61
79
|
});
|
62
80
|
|
@@ -2,13 +2,32 @@
|
|
2
2
|
|
3
3
|
import {expect} from "chai"
|
4
4
|
|
5
|
-
import {Template} from "../../../source/dom/template.js";
|
5
|
+
import {findDocumentTemplate, Template} from "../../../source/dom/template.js";
|
6
6
|
import {initJSDOM} from "../../util/jsdom.js";
|
7
7
|
|
8
|
+
const html1 = `
|
9
|
+
|
10
|
+
<template id="mytemplate"></template>
|
11
|
+
|
12
|
+
`;
|
13
|
+
|
14
|
+
|
8
15
|
describe('Template', function () {
|
16
|
+
|
9
17
|
before(async function () {
|
10
18
|
initJSDOM();
|
11
19
|
})
|
20
|
+
|
21
|
+
beforeEach(() => {
|
22
|
+
let mocks = document.getElementById('mocks');
|
23
|
+
mocks.innerHTML = html1;
|
24
|
+
})
|
25
|
+
|
26
|
+
afterEach(() => {
|
27
|
+
let mocks = document.getElementById('mocks');
|
28
|
+
mocks.innerHTML = "";
|
29
|
+
})
|
30
|
+
|
12
31
|
describe('create HTMLFragment', function () {
|
13
32
|
[
|
14
33
|
["<div>first</div><div>second</div>"],
|
@@ -46,4 +65,24 @@ describe('Template', function () {
|
|
46
65
|
});
|
47
66
|
});
|
48
67
|
|
68
|
+
describe('.findDocumentTemplate()', function () {
|
69
|
+
it('should throw Template not found', function () {
|
70
|
+
const div = document.createElement('div');
|
71
|
+
expect(() => {
|
72
|
+
findDocumentTemplate("noway", div)
|
73
|
+
}).to.throws(Error);
|
74
|
+
})
|
75
|
+
});
|
76
|
+
|
77
|
+
describe('.findDocumentTemplate()', function () {
|
78
|
+
it('should throw Template not found', function () {
|
79
|
+
const div = document.createElement('div');
|
80
|
+
div.remove();
|
81
|
+
let t = findDocumentTemplate("mytemplate", div);
|
82
|
+
expect(t).is.instanceof(Template);
|
83
|
+
|
84
|
+
})
|
85
|
+
});
|
86
|
+
|
87
|
+
|
49
88
|
});
|
package/test/cases/monster.js
CHANGED
@@ -12,6 +12,15 @@ describe('ProxyObserver', function () {
|
|
12
12
|
expect(o).is.instanceOf(ProxyObserver);
|
13
13
|
});
|
14
14
|
});
|
15
|
+
|
16
|
+
describe('proxy objects', function () {
|
17
|
+
it('Proxy objects should not be recommitted', function () {
|
18
|
+
let o = new ProxyObserver({a:{b:true}});
|
19
|
+
o.getSubject().a.b=o.getSubject();
|
20
|
+
o.getSubject().a.b.a.b=false;
|
21
|
+
//expect(o.getSubject()===p.getSubject()).to.be.true;
|
22
|
+
});
|
23
|
+
});
|
15
24
|
|
16
25
|
describe('notify observer', function () {
|
17
26
|
it('should inform observer', function (done) {
|
package/test/util/jsdom.js
CHANGED
@@ -34,6 +34,8 @@ function initJSDOM() {
|
|
34
34
|
'self',
|
35
35
|
'HTMLCollection',
|
36
36
|
'NodeList',
|
37
|
+
'ElementInternals',
|
38
|
+
'HTMLFormElement',
|
37
39
|
'HTMLInputElement',
|
38
40
|
'HTMLSelectElement',
|
39
41
|
'HTMLTextAreaElement',
|
@@ -54,6 +56,7 @@ function initJSDOM() {
|
|
54
56
|
'HTMLTemplateElement',
|
55
57
|
'XMLSerializer',
|
56
58
|
'NodeFilter',
|
59
|
+
'navigator',
|
57
60
|
'InputEvent',
|
58
61
|
'CustomEvent'
|
59
62
|
].forEach(key => (g[key] = window[key]));
|
package/test/web/import.js
CHANGED
@@ -9,6 +9,7 @@ import "../cases/dom/attributes.js";
|
|
9
9
|
import "../cases/dom/template.js";
|
10
10
|
import "../cases/dom/util.js";
|
11
11
|
import "../cases/dom/locale.js";
|
12
|
+
import "../cases/dom/customcontrol.js";
|
12
13
|
import "../cases/dom/assembler.js";
|
13
14
|
import "../cases/dom/theme.js";
|
14
15
|
import "../cases/dom/events.js";
|
@@ -10,13 +10,13 @@
|
|
10
10
|
crossorigin="anonymous"
|
11
11
|
referrerpolicy="no-referrer"></script>
|
12
12
|
|
13
|
-
<script src="https://monsterjs.org/dist/1.
|
13
|
+
<script src="https://monsterjs.org/dist/1.15.2/dist/monster.dev.js"></script>
|
14
14
|
|
15
15
|
</head>
|
16
16
|
<body>
|
17
17
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
18
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
19
|
-
<div id="lastupdate" style='font-size:0.7em'>last update Mo
|
18
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
|
19
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
|
20
20
|
</div>
|
21
21
|
</body>
|
22
22
|
</html>
|
package/test/web/monster.html
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
17
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
18
|
-
<div id="lastupdate" style='font-size:0.7em'>last update Mo
|
17
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
|
18
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
|
19
19
|
</div>
|
20
20
|
</body>
|
21
21
|
</html>
|
package/test/web/test.html
CHANGED
@@ -5,15 +5,15 @@
|
|
5
5
|
<title>Mocha Monster</title>
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
7
7
|
<link rel="stylesheet" href="mocha.css"/>
|
8
|
-
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,DataView,document,DocumentFragment,Element,Event,globalThis,HTMLDocument,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.trim,Symbol,Symbol.for,Symbol.iterator,Uint8Array,URL,WeakMap,WeakSet"
|
8
|
+
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,DataView,document,Document,DocumentFragment,Element,Event,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.trim,Symbol,Symbol.for,Symbol.iterator,Uint8Array,URL,WeakMap,WeakSet"
|
9
9
|
crossorigin="anonymous"
|
10
10
|
referrerpolicy="no-referrer"></script>
|
11
11
|
|
12
12
|
</head>
|
13
13
|
<body>
|
14
14
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
15
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 1.
|
16
|
-
<div id="lastupdate" style='font-size:0.7em'>last update Mo
|
15
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
|
16
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
|
17
17
|
</div>
|
18
18
|
<div id="mocks"></div>
|
19
19
|
<div id="mocha"></div>
|