pseudo-dom 0.6.0 → 0.8.0
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 +686 -241
- package/browser/pseudo-dom.js +3576 -735
- package/browser/pseudo-dom.min.js +1 -1
- package/dist/classes/PseudoEventListener.d.ts +96 -96
- package/dist/classes/PseudoEventListener.js +151 -151
- package/dist/classes/PseudoHTMLDocument.d.ts +17 -43
- package/dist/classes/PseudoHTMLDocument.js +24 -94
- package/dist/classes/PseudoHTMLDocument.min.js +1 -1
- package/dist/classes/PseudoNodeList.d.ts +34 -34
- package/dist/classes/PseudoNodeList.js +71 -71
- package/dist/factories/createEvent.d.ts +28 -28
- package/dist/factories/createEvent.js +56 -56
- package/dist/factories/cssSelectAdapter.d.ts +23 -0
- package/dist/factories/cssSelectAdapter.js +87 -0
- package/dist/factories/cssSelectAdapter.min.js +1 -0
- package/dist/factories/eventDefaults.d.ts +31 -31
- package/dist/factories/eventDefaults.js +105 -105
- package/dist/factories/generateDocument.d.ts +11 -11
- package/dist/factories/generateDocument.js +65 -65
- package/dist/factories/generateNodeList.d.ts +9 -9
- package/dist/factories/generateNodeList.js +13 -13
- package/dist/factories/query.d.ts +33 -0
- package/dist/factories/query.js +66 -0
- package/dist/factories/query.min.js +1 -0
- package/dist/functions/activeElement.d.ts +14 -14
- package/dist/functions/activeElement.js +33 -33
- package/dist/functions/getElementById.d.ts +13 -0
- package/dist/functions/getElementById.js +33 -0
- package/dist/functions/getElementById.min.js +1 -0
- package/dist/functions/getParentNodes.d.ts +11 -11
- package/dist/functions/getParentNodes.js +22 -22
- package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
- package/dist/functions/getParentNodesFromAttribute.js +29 -29
- package/dist/functions/modifierState.d.ts +29 -29
- package/dist/functions/modifierState.js +41 -41
- package/dist/interfaces/PseudoAnimation.d.ts +3 -3
- package/dist/interfaces/PseudoAnimation.js +5 -5
- package/dist/interfaces/PseudoAttr.d.ts +11 -11
- package/dist/interfaces/PseudoAttr.js +5 -5
- package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
- package/dist/interfaces/PseudoDOMTokenList.js +5 -5
- package/dist/interfaces/PseudoDocument.d.ts +32 -0
- package/dist/interfaces/PseudoDocument.js +5 -5
- package/dist/interfaces/PseudoDocumentFragment.d.ts +7 -0
- package/dist/interfaces/PseudoDocumentFragment.js +5 -5
- package/dist/interfaces/PseudoElement.d.ts +702 -689
- package/dist/interfaces/PseudoElement.js +5 -5
- package/dist/interfaces/PseudoEvent.d.ts +79 -79
- package/dist/interfaces/PseudoEvent.js +10 -10
- package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
- package/dist/interfaces/PseudoEventTarget.js +5 -5
- package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
- package/dist/interfaces/PseudoHTMLCollection.js +5 -5
- package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
- package/dist/interfaces/PseudoHTMLElement.js +5 -5
- package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
- package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
- package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
- package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
- package/dist/interfaces/PseudoNode.d.ts +179 -179
- package/dist/interfaces/PseudoNode.js +5 -5
- package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
- package/dist/interfaces/PseudoShadowRoot.js +5 -5
- package/dist/main.d.ts +63 -63
- package/dist/main.js +155 -155
- package/dist/services/AnimationService.d.ts +4 -4
- package/dist/services/AnimationService.js +16 -16
- package/dist/services/AttrService.d.ts +37 -37
- package/dist/services/AttrService.js +81 -81
- package/dist/services/CommentService.d.ts +1 -1
- package/dist/services/CommentService.js +13 -13
- package/dist/services/CustomEventService.d.ts +37 -37
- package/dist/services/CustomEventService.js +35 -35
- package/dist/services/DOMTokenListService.d.ts +33 -33
- package/dist/services/DOMTokenListService.js +117 -117
- package/dist/services/DocumentFragmentService.d.ts +8 -0
- package/dist/services/DocumentFragmentService.js +18 -0
- package/dist/services/DocumentFragmentService.min.js +1 -1
- package/dist/services/DocumentService.d.ts +35 -1
- package/dist/services/DocumentService.js +72 -0
- package/dist/services/DocumentService.min.js +1 -1
- package/dist/services/ElementService.d.ts +191 -178
- package/dist/services/ElementService.js +426 -406
- package/dist/services/ElementService.min.js +1 -1
- package/dist/services/EventService.d.ts +120 -120
- package/dist/services/EventService.js +250 -250
- package/dist/services/EventTargetService.d.ts +84 -84
- package/dist/services/EventTargetService.js +232 -232
- package/dist/services/FocusEventService.d.ts +32 -32
- package/dist/services/FocusEventService.js +35 -35
- package/dist/services/HTMLCollectionService.d.ts +54 -49
- package/dist/services/HTMLCollectionService.js +92 -75
- package/dist/services/HTMLCollectionService.min.js +1 -1
- package/dist/services/HTMLElementService.d.ts +57 -57
- package/dist/services/HTMLElementService.js +163 -163
- package/dist/services/HTMLSlotElementService.d.ts +4 -4
- package/dist/services/HTMLSlotElementService.js +9 -9
- package/dist/services/InputEventService.d.ts +41 -41
- package/dist/services/InputEventService.js +47 -47
- package/dist/services/KeyboardEventService.d.ts +70 -70
- package/dist/services/KeyboardEventService.js +86 -86
- package/dist/services/MouseEventService.d.ts +80 -80
- package/dist/services/MouseEventService.js +108 -108
- package/dist/services/NamedNodeMapService.d.ts +23 -23
- package/dist/services/NamedNodeMapService.js +77 -77
- package/dist/services/NodeService.d.ts +297 -271
- package/dist/services/NodeService.js +721 -679
- package/dist/services/NodeService.min.js +1 -1
- package/dist/services/PointerEventService.d.ts +51 -51
- package/dist/services/PointerEventService.js +67 -67
- package/dist/services/ShadowRootService.d.ts +4 -4
- package/dist/services/ShadowRootService.js +9 -9
- package/dist/services/TextService.d.ts +1 -1
- package/dist/services/TextService.js +13 -13
- package/dist/services/UIEventService.d.ts +43 -43
- package/dist/services/UIEventService.js +42 -42
- package/dist/simulate.d.ts +32 -32
- package/dist/simulate.js +115 -115
- package/package.json +4 -3
- package/dist/classes.d.ts +0 -20
- package/dist/classes.js +0 -31
- package/dist/classes.min.js +0 -1
- package/dist/factories/generateNode.d.ts +0 -32
- package/dist/factories/generateNode.js +0 -85
- package/dist/factories/generateNode.min.js +0 -1
- package/dist/factories.d.ts +0 -11
- package/dist/factories.js +0 -27
- package/dist/factories.min.js +0 -1
- package/dist/functions.d.ts +0 -5
- package/dist/functions.js +0 -23
- package/dist/functions.min.js +0 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Substitute for the DOM CustomEvent Class.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
6
|
-
import { EventService } from './EventService';
|
|
7
|
-
/**
|
|
8
|
-
* The options for creating a custom event.
|
|
9
|
-
* @typedef {Object} CustomEventInit
|
|
10
|
-
* @property {boolean} [bubbles=false]
|
|
11
|
-
* @property {boolean} [cancelable=false]
|
|
12
|
-
* @property {boolean} [composed=false]
|
|
13
|
-
* @property {*} [detail=null] Whatever data the event should carry
|
|
14
|
-
*/
|
|
15
|
-
export type CustomEventInit = {
|
|
16
|
-
bubbles?: boolean;
|
|
17
|
-
cancelable?: boolean;
|
|
18
|
-
composed?: boolean;
|
|
19
|
-
detail?: any;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
|
|
23
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
24
|
-
* @class
|
|
25
|
-
* @augments EventService
|
|
26
|
-
* @property {*} detail
|
|
27
|
-
*/
|
|
28
|
-
export declare class CustomEventService extends EventService {
|
|
29
|
-
private readonly eventDetail;
|
|
30
|
-
/**
|
|
31
|
-
* @param {string} [typeArg=''] The type of the event
|
|
32
|
-
* @param {CustomEventInit} [init={}] The options for the event
|
|
33
|
-
* @constructor
|
|
34
|
-
*/
|
|
35
|
-
constructor(typeArg?: string, init?: CustomEventInit);
|
|
36
|
-
get detail(): any;
|
|
37
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM CustomEvent Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventService } from './EventService';
|
|
7
|
+
/**
|
|
8
|
+
* The options for creating a custom event.
|
|
9
|
+
* @typedef {Object} CustomEventInit
|
|
10
|
+
* @property {boolean} [bubbles=false]
|
|
11
|
+
* @property {boolean} [cancelable=false]
|
|
12
|
+
* @property {boolean} [composed=false]
|
|
13
|
+
* @property {*} [detail=null] Whatever data the event should carry
|
|
14
|
+
*/
|
|
15
|
+
export type CustomEventInit = {
|
|
16
|
+
bubbles?: boolean;
|
|
17
|
+
cancelable?: boolean;
|
|
18
|
+
composed?: boolean;
|
|
19
|
+
detail?: any;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
|
|
23
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
24
|
+
* @class
|
|
25
|
+
* @augments EventService
|
|
26
|
+
* @property {*} detail
|
|
27
|
+
*/
|
|
28
|
+
export declare class CustomEventService extends EventService {
|
|
29
|
+
private readonly eventDetail;
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} [typeArg=''] The type of the event
|
|
32
|
+
* @param {CustomEventInit} [init={}] The options for the event
|
|
33
|
+
* @constructor
|
|
34
|
+
*/
|
|
35
|
+
constructor(typeArg?: string, init?: CustomEventInit);
|
|
36
|
+
get detail(): any;
|
|
37
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.CustomEventService = void 0
|
|
7
|
-
/**
|
|
8
|
-
* @file Substitute for the DOM CustomEvent Class.
|
|
9
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
*/
|
|
12
|
-
const EventService_1 = require('./EventService')
|
|
13
|
-
/**
|
|
14
|
-
* Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
|
|
15
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
-
* @class
|
|
17
|
-
* @augments EventService
|
|
18
|
-
* @property {*} detail
|
|
19
|
-
*/
|
|
20
|
-
class CustomEventService extends EventService_1.EventService {
|
|
21
|
-
/**
|
|
22
|
-
* @param {string} [typeArg=''] The type of the event
|
|
23
|
-
* @param {CustomEventInit} [init={}] The options for the event
|
|
24
|
-
* @constructor
|
|
25
|
-
*/
|
|
26
|
-
constructor (typeArg = '', init = {}) {
|
|
27
|
-
super(typeArg, init)
|
|
28
|
-
this.eventDetail = typeof init.detail === 'undefined' ? null : init.detail
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get detail () {
|
|
32
|
-
return this.eventDetail
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.CustomEventService = CustomEventService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.CustomEventService = void 0
|
|
7
|
+
/**
|
|
8
|
+
* @file Substitute for the DOM CustomEvent Class.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
const EventService_1 = require('./EventService')
|
|
13
|
+
/**
|
|
14
|
+
* Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
|
|
15
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
+
* @class
|
|
17
|
+
* @augments EventService
|
|
18
|
+
* @property {*} detail
|
|
19
|
+
*/
|
|
20
|
+
class CustomEventService extends EventService_1.EventService {
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} [typeArg=''] The type of the event
|
|
23
|
+
* @param {CustomEventInit} [init={}] The options for the event
|
|
24
|
+
* @constructor
|
|
25
|
+
*/
|
|
26
|
+
constructor (typeArg = '', init = {}) {
|
|
27
|
+
super(typeArg, init)
|
|
28
|
+
this.eventDetail = typeof init.detail === 'undefined' ? null : init.detail
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get detail () {
|
|
32
|
+
return this.eventDetail
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CustomEventService = CustomEventService
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { PseudoDOMTokenList } from '../interfaces/PseudoDOMTokenList';
|
|
2
|
-
/**
|
|
3
|
-
* Simulate the behaviour of the DOMTokenList Class when there is no DOM available.
|
|
4
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
export declare class DOMTokenListService implements PseudoDOMTokenList {
|
|
8
|
-
private tokens;
|
|
9
|
-
private readonly onChange;
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} [value=''] The space separated tokens to start with
|
|
12
|
-
* @param {function(string): void} [onChange] Called with the new value whenever the tokens change
|
|
13
|
-
* @constructor
|
|
14
|
-
*/
|
|
15
|
-
constructor(value?: string, onChange?: (value: string) => void);
|
|
16
|
-
private static parse;
|
|
17
|
-
private update;
|
|
18
|
-
private static validate;
|
|
19
|
-
get length(): number;
|
|
20
|
-
get value(): string;
|
|
21
|
-
set value(value: string);
|
|
22
|
-
item(index: number): string | null;
|
|
23
|
-
contains(token: string): boolean;
|
|
24
|
-
add(...tokens: string[]): void;
|
|
25
|
-
remove(...tokens: string[]): void;
|
|
26
|
-
replace(oldToken: string, newToken: string): boolean;
|
|
27
|
-
supports(token: string): boolean;
|
|
28
|
-
toggle(token: string, force?: boolean): boolean;
|
|
29
|
-
entries(): Iterator<[number, string]>;
|
|
30
|
-
forEach(callback: Function, thisArg?: any): void;
|
|
31
|
-
keys(): Iterator<number>;
|
|
32
|
-
values(): Iterator<string>;
|
|
33
|
-
}
|
|
1
|
+
import { PseudoDOMTokenList } from '../interfaces/PseudoDOMTokenList';
|
|
2
|
+
/**
|
|
3
|
+
* Simulate the behaviour of the DOMTokenList Class when there is no DOM available.
|
|
4
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
export declare class DOMTokenListService implements PseudoDOMTokenList {
|
|
8
|
+
private tokens;
|
|
9
|
+
private readonly onChange;
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} [value=''] The space separated tokens to start with
|
|
12
|
+
* @param {function(string): void} [onChange] Called with the new value whenever the tokens change
|
|
13
|
+
* @constructor
|
|
14
|
+
*/
|
|
15
|
+
constructor(value?: string, onChange?: (value: string) => void);
|
|
16
|
+
private static parse;
|
|
17
|
+
private update;
|
|
18
|
+
private static validate;
|
|
19
|
+
get length(): number;
|
|
20
|
+
get value(): string;
|
|
21
|
+
set value(value: string);
|
|
22
|
+
item(index: number): string | null;
|
|
23
|
+
contains(token: string): boolean;
|
|
24
|
+
add(...tokens: string[]): void;
|
|
25
|
+
remove(...tokens: string[]): void;
|
|
26
|
+
replace(oldToken: string, newToken: string): boolean;
|
|
27
|
+
supports(token: string): boolean;
|
|
28
|
+
toggle(token: string, force?: boolean): boolean;
|
|
29
|
+
entries(): Iterator<[number, string]>;
|
|
30
|
+
forEach(callback: Function, thisArg?: any): void;
|
|
31
|
+
keys(): Iterator<number>;
|
|
32
|
+
values(): Iterator<string>;
|
|
33
|
+
}
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
-
require('core-js/modules/esnext.iterator.filter.js')
|
|
5
|
-
require('core-js/modules/esnext.iterator.for-each.js')
|
|
6
|
-
require('core-js/modules/esnext.iterator.map.js')
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {
|
|
8
|
-
value: true
|
|
9
|
-
})
|
|
10
|
-
exports.DOMTokenListService = void 0
|
|
11
|
-
/**
|
|
12
|
-
* Simulate the behaviour of the DOMTokenList Class when there is no DOM available.
|
|
13
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
14
|
-
* @class
|
|
15
|
-
*/
|
|
16
|
-
class DOMTokenListService {
|
|
17
|
-
/**
|
|
18
|
-
* @param {string} [value=''] The space separated tokens to start with
|
|
19
|
-
* @param {function(string): void} [onChange] Called with the new value whenever the tokens change
|
|
20
|
-
* @constructor
|
|
21
|
-
*/
|
|
22
|
-
constructor (value = '', onChange = () => undefined) {
|
|
23
|
-
this.tokens = DOMTokenListService.parse(value)
|
|
24
|
-
this.onChange = onChange
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static parse (value) {
|
|
28
|
-
return (value || '').split(/\s+/).filter((token, index, tokens) => token !== '' && tokens.indexOf(token) === index)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
update (tokens) {
|
|
32
|
-
this.tokens = tokens
|
|
33
|
-
this.onChange(this.value)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static validate (token) {
|
|
37
|
-
if (token === '') {
|
|
38
|
-
throw new SyntaxError('The token provided must not be empty.')
|
|
39
|
-
}
|
|
40
|
-
if (/\s/.test(token)) {
|
|
41
|
-
throw new Error('The token provided contains whitespace.')
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get length () {
|
|
46
|
-
return this.tokens.length
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get value () {
|
|
50
|
-
return this.tokens.join(' ')
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
set value (value) {
|
|
54
|
-
this.update(DOMTokenListService.parse(value))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
item (index) {
|
|
58
|
-
return index >= 0 && index < this.tokens.length ? this.tokens[index] : null
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
contains (token) {
|
|
62
|
-
return this.tokens.indexOf(token) >= 0
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
add (...tokens) {
|
|
66
|
-
tokens.forEach(DOMTokenListService.validate)
|
|
67
|
-
this.update(this.tokens.concat(tokens).filter((token, index, all) => all.indexOf(token) === index))
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
remove (...tokens) {
|
|
71
|
-
tokens.forEach(DOMTokenListService.validate)
|
|
72
|
-
this.update(this.tokens.filter(token => tokens.indexOf(token) < 0))
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
replace (oldToken, newToken) {
|
|
76
|
-
DOMTokenListService.validate(oldToken)
|
|
77
|
-
DOMTokenListService.validate(newToken)
|
|
78
|
-
if (!this.contains(oldToken)) {
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
this.update(this.tokens.map(token => token === oldToken ? newToken : token).filter((token, index, all) => all.indexOf(token) === index))
|
|
82
|
-
return true
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
supports (token) {
|
|
86
|
-
// There is no list of supported tokens for arbitrary attributes, so like the DOM (for those) this is unsupported
|
|
87
|
-
throw new TypeError(`Failed to execute 'supports' on 'DOMTokenList': DOMTokenList has no supported tokens (${token}).`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
toggle (token, force) {
|
|
91
|
-
DOMTokenListService.validate(token)
|
|
92
|
-
const shouldHave = typeof force === 'boolean' ? force : !this.contains(token)
|
|
93
|
-
if (shouldHave) {
|
|
94
|
-
this.add(token)
|
|
95
|
-
} else {
|
|
96
|
-
this.remove(token)
|
|
97
|
-
}
|
|
98
|
-
return shouldHave
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
entries () {
|
|
102
|
-
return this.tokens.map((token, index) => [index, token])[Symbol.iterator]()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
forEach (callback, thisArg) {
|
|
106
|
-
this.tokens.forEach((token, index) => callback.call(thisArg, token, index, this))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
keys () {
|
|
110
|
-
return this.tokens.map((token, index) => index)[Symbol.iterator]()
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
values () {
|
|
114
|
-
return this.tokens.slice()[Symbol.iterator]()
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.DOMTokenListService = DOMTokenListService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.filter.js')
|
|
5
|
+
require('core-js/modules/esnext.iterator.for-each.js')
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js')
|
|
7
|
+
Object.defineProperty(exports, '__esModule', {
|
|
8
|
+
value: true
|
|
9
|
+
})
|
|
10
|
+
exports.DOMTokenListService = void 0
|
|
11
|
+
/**
|
|
12
|
+
* Simulate the behaviour of the DOMTokenList Class when there is no DOM available.
|
|
13
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
14
|
+
* @class
|
|
15
|
+
*/
|
|
16
|
+
class DOMTokenListService {
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} [value=''] The space separated tokens to start with
|
|
19
|
+
* @param {function(string): void} [onChange] Called with the new value whenever the tokens change
|
|
20
|
+
* @constructor
|
|
21
|
+
*/
|
|
22
|
+
constructor (value = '', onChange = () => undefined) {
|
|
23
|
+
this.tokens = DOMTokenListService.parse(value)
|
|
24
|
+
this.onChange = onChange
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static parse (value) {
|
|
28
|
+
return (value || '').split(/\s+/).filter((token, index, tokens) => token !== '' && tokens.indexOf(token) === index)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
update (tokens) {
|
|
32
|
+
this.tokens = tokens
|
|
33
|
+
this.onChange(this.value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static validate (token) {
|
|
37
|
+
if (token === '') {
|
|
38
|
+
throw new SyntaxError('The token provided must not be empty.')
|
|
39
|
+
}
|
|
40
|
+
if (/\s/.test(token)) {
|
|
41
|
+
throw new Error('The token provided contains whitespace.')
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get length () {
|
|
46
|
+
return this.tokens.length
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get value () {
|
|
50
|
+
return this.tokens.join(' ')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set value (value) {
|
|
54
|
+
this.update(DOMTokenListService.parse(value))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
item (index) {
|
|
58
|
+
return index >= 0 && index < this.tokens.length ? this.tokens[index] : null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
contains (token) {
|
|
62
|
+
return this.tokens.indexOf(token) >= 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
add (...tokens) {
|
|
66
|
+
tokens.forEach(DOMTokenListService.validate)
|
|
67
|
+
this.update(this.tokens.concat(tokens).filter((token, index, all) => all.indexOf(token) === index))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
remove (...tokens) {
|
|
71
|
+
tokens.forEach(DOMTokenListService.validate)
|
|
72
|
+
this.update(this.tokens.filter(token => tokens.indexOf(token) < 0))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
replace (oldToken, newToken) {
|
|
76
|
+
DOMTokenListService.validate(oldToken)
|
|
77
|
+
DOMTokenListService.validate(newToken)
|
|
78
|
+
if (!this.contains(oldToken)) {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
this.update(this.tokens.map(token => token === oldToken ? newToken : token).filter((token, index, all) => all.indexOf(token) === index))
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
supports (token) {
|
|
86
|
+
// There is no list of supported tokens for arbitrary attributes, so like the DOM (for those) this is unsupported
|
|
87
|
+
throw new TypeError(`Failed to execute 'supports' on 'DOMTokenList': DOMTokenList has no supported tokens (${token}).`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
toggle (token, force) {
|
|
91
|
+
DOMTokenListService.validate(token)
|
|
92
|
+
const shouldHave = typeof force === 'boolean' ? force : !this.contains(token)
|
|
93
|
+
if (shouldHave) {
|
|
94
|
+
this.add(token)
|
|
95
|
+
} else {
|
|
96
|
+
this.remove(token)
|
|
97
|
+
}
|
|
98
|
+
return shouldHave
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
entries () {
|
|
102
|
+
return this.tokens.map((token, index) => [index, token])[Symbol.iterator]()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
forEach (callback, thisArg) {
|
|
106
|
+
this.tokens.forEach((token, index) => callback.call(thisArg, token, index, this))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
keys () {
|
|
110
|
+
return this.tokens.map((token, index) => index)[Symbol.iterator]()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
values () {
|
|
114
|
+
return this.tokens.slice()[Symbol.iterator]()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.DOMTokenListService = DOMTokenListService
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeService } from './NodeService';
|
|
2
2
|
import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
3
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
3
4
|
/**
|
|
4
5
|
* Simulate the behaviour of the DocumentFragment Class when there is no DOM available: a container for nodes which is
|
|
5
6
|
* not part of a tree, when it is inserted its children are moved into the tree instead.
|
|
@@ -10,4 +11,11 @@ import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
|
10
11
|
export declare class DocumentFragmentService extends NodeService implements PseudoDocumentFragment {
|
|
11
12
|
get nodeName(): string;
|
|
12
13
|
get nodeType(): number;
|
|
14
|
+
/**
|
|
15
|
+
* The first element, in tree order, whose id matches the given value, or null when there is none (the DOM's
|
|
16
|
+
* NonElementParentNode mixin, which Document and DocumentFragment both implement).
|
|
17
|
+
* @param {string} id
|
|
18
|
+
* @returns {PseudoElement|null}
|
|
19
|
+
*/
|
|
20
|
+
getElementById(id: string): PseudoElement | null;
|
|
13
21
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule
|
|
5
|
+
? mod
|
|
6
|
+
: {
|
|
7
|
+
default: mod
|
|
8
|
+
}
|
|
9
|
+
}
|
|
3
10
|
Object.defineProperty(exports, '__esModule', {
|
|
4
11
|
value: true
|
|
5
12
|
})
|
|
6
13
|
exports.DocumentFragmentService = void 0
|
|
7
14
|
const NodeService_1 = require('./NodeService')
|
|
15
|
+
const getElementById_1 = __importDefault(require('../functions/getElementById'))
|
|
8
16
|
/**
|
|
9
17
|
* Simulate the behaviour of the DocumentFragment Class when there is no DOM available: a container for nodes which is
|
|
10
18
|
* not part of a tree, when it is inserted its children are moved into the tree instead.
|
|
@@ -20,5 +28,15 @@ class DocumentFragmentService extends NodeService_1.NodeService {
|
|
|
20
28
|
get nodeType () {
|
|
21
29
|
return NodeService_1.NodeService.DOCUMENT_FRAGMENT_NODE
|
|
22
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The first element, in tree order, whose id matches the given value, or null when there is none (the DOM's
|
|
34
|
+
* NonElementParentNode mixin, which Document and DocumentFragment both implement).
|
|
35
|
+
* @param {string} id
|
|
36
|
+
* @returns {PseudoElement|null}
|
|
37
|
+
*/
|
|
38
|
+
getElementById (id) {
|
|
39
|
+
return (0, getElementById_1.default)(this, id)
|
|
40
|
+
}
|
|
23
41
|
}
|
|
24
42
|
exports.DocumentFragmentService = DocumentFragmentService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentFragmentService=void 0;const NodeService_1=require("./NodeService");class DocumentFragmentService extends NodeService_1.NodeService{get nodeName(){return"#document-fragment"}get nodeType(){return NodeService_1.NodeService.DOCUMENT_FRAGMENT_NODE}}exports.DocumentFragmentService=DocumentFragmentService;
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentFragmentService=void 0;const NodeService_1=require("./NodeService"),getElementById_1=__importDefault(require("../functions/getElementById"));class DocumentFragmentService extends NodeService_1.NodeService{get nodeName(){return"#document-fragment"}get nodeType(){return NodeService_1.NodeService.DOCUMENT_FRAGMENT_NODE}getElementById(e){return(0,getElementById_1.default)(this,e)}}exports.DocumentFragmentService=DocumentFragmentService;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { NodeService } from './NodeService';
|
|
1
|
+
import { NodeService, TextService, CommentService } from './NodeService';
|
|
2
2
|
import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
3
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
4
|
+
import { DocumentFragmentService } from './DocumentFragmentService';
|
|
3
5
|
/**
|
|
4
6
|
* Simulate the behaviour of the Document Class when there is no DOM available.
|
|
5
7
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -9,4 +11,36 @@ import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
|
9
11
|
export declare class DocumentService extends NodeService implements PseudoDocument {
|
|
10
12
|
get nodeName(): string;
|
|
11
13
|
get nodeType(): number;
|
|
14
|
+
get textContent(): string | null;
|
|
15
|
+
set textContent(text: string | null);
|
|
16
|
+
/**
|
|
17
|
+
* The first element, in tree order, whose id matches the given value, or null when there is none.
|
|
18
|
+
* @param {string} id
|
|
19
|
+
* @returns {PseudoElement|null}
|
|
20
|
+
*/
|
|
21
|
+
getElementById(id: string): PseudoElement | null;
|
|
22
|
+
/**
|
|
23
|
+
* Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
|
|
24
|
+
* @param {string} [tagName='div'] The type of element to create
|
|
25
|
+
* @returns {PseudoElement}
|
|
26
|
+
*/
|
|
27
|
+
createElement(tagName?: string): PseudoElement;
|
|
28
|
+
/**
|
|
29
|
+
* Make a text node which belongs to this document.
|
|
30
|
+
* @param {string} [data=''] The text
|
|
31
|
+
* @returns {TextService}
|
|
32
|
+
*/
|
|
33
|
+
createTextNode(data?: string): TextService;
|
|
34
|
+
/**
|
|
35
|
+
* Make a comment which belongs to this document.
|
|
36
|
+
* @param {string} [data=''] The comment
|
|
37
|
+
* @returns {CommentService}
|
|
38
|
+
*/
|
|
39
|
+
createComment(data?: string): CommentService;
|
|
40
|
+
/**
|
|
41
|
+
* Make an empty document fragment which belongs to this document, a container for nodes which can be built up and
|
|
42
|
+
* then inserted in one go.
|
|
43
|
+
* @returns {DocumentFragmentService}
|
|
44
|
+
*/
|
|
45
|
+
createDocumentFragment(): DocumentFragmentService;
|
|
12
46
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule
|
|
5
|
+
? mod
|
|
6
|
+
: {
|
|
7
|
+
default: mod
|
|
8
|
+
}
|
|
9
|
+
}
|
|
3
10
|
Object.defineProperty(exports, '__esModule', {
|
|
4
11
|
value: true
|
|
5
12
|
})
|
|
6
13
|
exports.DocumentService = void 0
|
|
7
14
|
const NodeService_1 = require('./NodeService')
|
|
15
|
+
const HTMLElementService_1 = require('./HTMLElementService')
|
|
16
|
+
const DocumentFragmentService_1 = require('./DocumentFragmentService')
|
|
17
|
+
const getElementById_1 = __importDefault(require('../functions/getElementById'))
|
|
8
18
|
/**
|
|
9
19
|
* Simulate the behaviour of the Document Class when there is no DOM available.
|
|
10
20
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -19,5 +29,67 @@ class DocumentService extends NodeService_1.NodeService {
|
|
|
19
29
|
get nodeType () {
|
|
20
30
|
return NodeService_1.NodeService.DOCUMENT_NODE
|
|
21
31
|
}
|
|
32
|
+
|
|
33
|
+
// A document has no text of its own, and setting it does nothing
|
|
34
|
+
get textContent () {
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set textContent (text) {}
|
|
39
|
+
/**
|
|
40
|
+
* The first element, in tree order, whose id matches the given value, or null when there is none.
|
|
41
|
+
* @param {string} id
|
|
42
|
+
* @returns {PseudoElement|null}
|
|
43
|
+
*/
|
|
44
|
+
getElementById (id) {
|
|
45
|
+
return (0, getElementById_1.default)(this, id)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
|
|
50
|
+
* @param {string} [tagName='div'] The type of element to create
|
|
51
|
+
* @returns {PseudoElement}
|
|
52
|
+
*/
|
|
53
|
+
createElement (tagName = 'div') {
|
|
54
|
+
// Like the DOM, the new element is not added anywhere: it has no parent until it is appended
|
|
55
|
+
const element = new HTMLElementService_1.HTMLElementService({
|
|
56
|
+
tagName
|
|
57
|
+
})
|
|
58
|
+
element.ownerDocumentStore = this
|
|
59
|
+
return element
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Make a text node which belongs to this document.
|
|
64
|
+
* @param {string} [data=''] The text
|
|
65
|
+
* @returns {TextService}
|
|
66
|
+
*/
|
|
67
|
+
createTextNode (data = '') {
|
|
68
|
+
const text = new NodeService_1.TextService(data)
|
|
69
|
+
text.ownerDocumentStore = this
|
|
70
|
+
return text
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Make a comment which belongs to this document.
|
|
75
|
+
* @param {string} [data=''] The comment
|
|
76
|
+
* @returns {CommentService}
|
|
77
|
+
*/
|
|
78
|
+
createComment (data = '') {
|
|
79
|
+
const comment = new NodeService_1.CommentService(data)
|
|
80
|
+
comment.ownerDocumentStore = this
|
|
81
|
+
return comment
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Make an empty document fragment which belongs to this document, a container for nodes which can be built up and
|
|
86
|
+
* then inserted in one go.
|
|
87
|
+
* @returns {DocumentFragmentService}
|
|
88
|
+
*/
|
|
89
|
+
createDocumentFragment () {
|
|
90
|
+
const fragment = new DocumentFragmentService_1.DocumentFragmentService()
|
|
91
|
+
fragment.ownerDocumentStore = this
|
|
92
|
+
return fragment
|
|
93
|
+
}
|
|
22
94
|
}
|
|
23
95
|
exports.DocumentService = DocumentService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentService=void 0;const NodeService_1=require("./NodeService");class DocumentService extends NodeService_1.NodeService{get nodeName(){return"#document"}get nodeType(){return NodeService_1.NodeService.DOCUMENT_NODE}}exports.DocumentService=DocumentService;
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentService=void 0;const NodeService_1=require("./NodeService"),HTMLElementService_1=require("./HTMLElementService"),DocumentFragmentService_1=require("./DocumentFragmentService"),getElementById_1=__importDefault(require("../functions/getElementById"));class DocumentService extends NodeService_1.NodeService{get nodeName(){return"#document"}get nodeType(){return NodeService_1.NodeService.DOCUMENT_NODE}get textContent(){return null}set textContent(e){}getElementById(e){return(0,getElementById_1.default)(this,e)}createElement(e="div"){const t=new HTMLElementService_1.HTMLElementService({tagName:e});return t.ownerDocumentStore=this,t}createTextNode(e=""){const t=new NodeService_1.TextService(e);return t.ownerDocumentStore=this,t}createComment(e=""){const t=new NodeService_1.CommentService(e);return t.ownerDocumentStore=this,t}createDocumentFragment(){const e=new DocumentFragmentService_1.DocumentFragmentService;return e.ownerDocumentStore=this,e}}exports.DocumentService=DocumentService;
|