pseudo-dom 0.1.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/LICENSE +674 -0
- package/README.md +1029 -0
- package/browser/pseudo-dom.js +5219 -0
- package/browser/pseudo-dom.min.js +1 -0
- package/dist/classes/PseudoEventListener.d.ts +96 -0
- package/dist/classes/PseudoEventListener.js +148 -0
- package/dist/classes/PseudoEventListener.min.js +1 -0
- package/dist/classes/PseudoHTMLDocument.d.ts +35 -0
- package/dist/classes/PseudoHTMLDocument.js +77 -0
- package/dist/classes/PseudoHTMLDocument.min.js +1 -0
- package/dist/classes/PseudoNodeList.d.ts +34 -0
- package/dist/classes/PseudoNodeList.js +65 -0
- package/dist/classes/PseudoNodeList.min.js +1 -0
- package/dist/classes.d.ts +20 -0
- package/dist/classes.js +31 -0
- package/dist/classes.min.js +1 -0
- package/dist/factories/generateDocument.d.ts +11 -0
- package/dist/factories/generateDocument.js +65 -0
- package/dist/factories/generateDocument.min.js +1 -0
- package/dist/factories/generateNode.d.ts +40 -0
- package/dist/factories/generateNode.js +118 -0
- package/dist/factories/generateNode.min.js +1 -0
- package/dist/factories/generateNodeList.d.ts +9 -0
- package/dist/factories/generateNodeList.js +13 -0
- package/dist/factories/generateNodeList.min.js +1 -0
- package/dist/factories.d.ts +5 -0
- package/dist/factories.js +23 -0
- package/dist/factories.min.js +1 -0
- package/dist/functions/getParentNodes.d.ts +9 -0
- package/dist/functions/getParentNodes.js +15 -0
- package/dist/functions/getParentNodes.min.js +1 -0
- package/dist/functions/getParentNodesFromAttribute.d.ts +14 -0
- package/dist/functions/getParentNodesFromAttribute.js +9 -0
- package/dist/functions/getParentNodesFromAttribute.min.js +1 -0
- package/dist/functions.d.ts +5 -0
- package/dist/functions.js +23 -0
- package/dist/functions.min.js +1 -0
- package/dist/interfaces/PseudoAnimation.d.ts +3 -0
- package/dist/interfaces/PseudoAnimation.js +5 -0
- package/dist/interfaces/PseudoAnimation.min.js +1 -0
- package/dist/interfaces/PseudoAttr.d.ts +11 -0
- package/dist/interfaces/PseudoAttr.js +5 -0
- package/dist/interfaces/PseudoAttr.min.js +1 -0
- package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -0
- package/dist/interfaces/PseudoDOMTokenList.js +5 -0
- package/dist/interfaces/PseudoDOMTokenList.min.js +1 -0
- package/dist/interfaces/PseudoDocument.d.ts +3 -0
- package/dist/interfaces/PseudoDocument.js +5 -0
- package/dist/interfaces/PseudoDocument.min.js +1 -0
- package/dist/interfaces/PseudoDocumentFragment.d.ts +3 -0
- package/dist/interfaces/PseudoDocumentFragment.js +5 -0
- package/dist/interfaces/PseudoDocumentFragment.min.js +1 -0
- package/dist/interfaces/PseudoElement.d.ts +678 -0
- package/dist/interfaces/PseudoElement.js +5 -0
- package/dist/interfaces/PseudoElement.min.js +1 -0
- package/dist/interfaces/PseudoEvent.d.ts +79 -0
- package/dist/interfaces/PseudoEvent.js +10 -0
- package/dist/interfaces/PseudoEvent.min.js +1 -0
- package/dist/interfaces/PseudoEventTarget.d.ts +46 -0
- package/dist/interfaces/PseudoEventTarget.js +5 -0
- package/dist/interfaces/PseudoEventTarget.min.js +1 -0
- package/dist/interfaces/PseudoHTMLCollection.d.ts +2 -0
- package/dist/interfaces/PseudoHTMLCollection.js +5 -0
- package/dist/interfaces/PseudoHTMLCollection.min.js +1 -0
- package/dist/interfaces/PseudoHTMLElement.d.ts +22 -0
- package/dist/interfaces/PseudoHTMLElement.js +5 -0
- package/dist/interfaces/PseudoHTMLElement.min.js +1 -0
- package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -0
- package/dist/interfaces/PseudoHTMLSlotElement.js +5 -0
- package/dist/interfaces/PseudoHTMLSlotElement.min.js +1 -0
- package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -0
- package/dist/interfaces/PseudoNamedNodeMap.js +5 -0
- package/dist/interfaces/PseudoNamedNodeMap.min.js +1 -0
- package/dist/interfaces/PseudoNode.d.ts +179 -0
- package/dist/interfaces/PseudoNode.js +5 -0
- package/dist/interfaces/PseudoNode.min.js +1 -0
- package/dist/interfaces/PseudoShadowRoot.d.ts +3 -0
- package/dist/interfaces/PseudoShadowRoot.js +5 -0
- package/dist/interfaces/PseudoShadowRoot.min.js +1 -0
- package/dist/main.d.ts +29 -0
- package/dist/main.js +75 -0
- package/dist/main.min.js +1 -0
- package/dist/services/AnimationService.d.ts +4 -0
- package/dist/services/AnimationService.js +16 -0
- package/dist/services/AnimationService.min.js +1 -0
- package/dist/services/AttrService.d.ts +31 -0
- package/dist/services/AttrService.js +57 -0
- package/dist/services/AttrService.min.js +1 -0
- package/dist/services/DOMTokenListService.d.ts +33 -0
- package/dist/services/DOMTokenListService.js +117 -0
- package/dist/services/DOMTokenListService.min.js +1 -0
- package/dist/services/DocumentFragmentService.d.ts +4 -0
- package/dist/services/DocumentFragmentService.js +9 -0
- package/dist/services/DocumentFragmentService.min.js +1 -0
- package/dist/services/DocumentService.d.ts +4 -0
- package/dist/services/DocumentService.js +9 -0
- package/dist/services/DocumentService.min.js +1 -0
- package/dist/services/ElementService.d.ts +95 -0
- package/dist/services/ElementService.js +205 -0
- package/dist/services/ElementService.min.js +1 -0
- package/dist/services/EventService.d.ts +106 -0
- package/dist/services/EventService.js +216 -0
- package/dist/services/EventService.min.js +1 -0
- package/dist/services/EventTargetService.d.ts +52 -0
- package/dist/services/EventTargetService.js +163 -0
- package/dist/services/EventTargetService.min.js +1 -0
- package/dist/services/HTMLCollectionService.d.ts +3 -0
- package/dist/services/HTMLCollectionService.js +8 -0
- package/dist/services/HTMLCollectionService.min.js +1 -0
- package/dist/services/HTMLElementService.d.ts +37 -0
- package/dist/services/HTMLElementService.js +68 -0
- package/dist/services/HTMLElementService.min.js +1 -0
- package/dist/services/HTMLSlotElementService.d.ts +4 -0
- package/dist/services/HTMLSlotElementService.js +9 -0
- package/dist/services/HTMLSlotElementService.min.js +1 -0
- package/dist/services/NamedNodeMapService.d.ts +23 -0
- package/dist/services/NamedNodeMapService.js +77 -0
- package/dist/services/NamedNodeMapService.min.js +1 -0
- package/dist/services/NodeService.d.ts +111 -0
- package/dist/services/NodeService.js +230 -0
- package/dist/services/NodeService.min.js +1 -0
- package/dist/services/ShadowRootService.d.ts +4 -0
- package/dist/services/ShadowRootService.js +9 -0
- package/dist/services/ShadowRootService.min.js +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM Event Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
7
|
+
/**
|
|
8
|
+
* Simulate the behaviour of the Event Class when there is no DOM available.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @class
|
|
11
|
+
* @property {number} NONE
|
|
12
|
+
* @property {number} CAPTURING_PHASE
|
|
13
|
+
* @property {number} AT_TARGET
|
|
14
|
+
* @property {number} BUBBLING_PHASE
|
|
15
|
+
* @property {boolean} bubbles - A Boolean indicating whether the event bubbles up through the Dom or not.
|
|
16
|
+
* @property {boolean} cancelable - A Boolean indicating whether the event is cancelable.
|
|
17
|
+
* @property {boolean} composed - A Boolean value indicating whether the event can bubble across the boundary
|
|
18
|
+
* between the shadow Dom and the regular Dom.
|
|
19
|
+
* @property {function|PseudoEventTarget} currentTarget - A reference to the currently registered target for the event. This
|
|
20
|
+
* is the object to which the event is currently slated to be sent; it's possible this has been changed along the way
|
|
21
|
+
* through re-targeting.
|
|
22
|
+
* @property {boolean} defaultPrevented - Indicates whether event.preventDefault() has been called on the event.
|
|
23
|
+
* @property {int} eventPhase - Indicates which phase of the event flow is being processed. Uses PseudoEvent constants.
|
|
24
|
+
* @property {EventTarget|PseudoEventTarget} target - A reference to the target to which the event was originally
|
|
25
|
+
* dispatched.
|
|
26
|
+
* @property {int} timeStamp - The time at which the event was created (in milliseconds). By specification, this
|
|
27
|
+
* value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this
|
|
28
|
+
* to be a DomHighResTimeStamp instead.
|
|
29
|
+
* @property {string} type - The name of the event (case-insensitive).
|
|
30
|
+
* @property {boolean} isTrusted - Indicates whether the event was initiated by the browser (after a user
|
|
31
|
+
* click for instance) or by a script (using an event creation method, like event.initEvent)
|
|
32
|
+
*/
|
|
33
|
+
export interface PseudoEvent {
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {string} type
|
|
37
|
+
* @param {Object} [eventOptions={}]
|
|
38
|
+
* @param {boolean} [eventOptions.bubbles=true]
|
|
39
|
+
* @param {boolean} [eventOptions.cancelable=true]
|
|
40
|
+
* @param {boolean} [eventOptions.composed=true]
|
|
41
|
+
* @constructor
|
|
42
|
+
*/
|
|
43
|
+
get bubbles(): boolean;
|
|
44
|
+
get cancelable(): boolean;
|
|
45
|
+
get composed(): boolean;
|
|
46
|
+
get currentTarget(): PseudoEventTarget;
|
|
47
|
+
get defaultPrevented(): boolean;
|
|
48
|
+
get eventPhase(): number;
|
|
49
|
+
get isTrusted(): boolean;
|
|
50
|
+
get target(): PseudoEventTarget;
|
|
51
|
+
get timeStamp(): number;
|
|
52
|
+
get type(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Return an array of targets that will have the event executed open them. The order is based on the eventPhase
|
|
55
|
+
* @method
|
|
56
|
+
* @returns {Array.<PseudoEventTarget>}
|
|
57
|
+
*/
|
|
58
|
+
composedPath(): Array<PseudoEventTarget>;
|
|
59
|
+
/**
|
|
60
|
+
* Cancels the event (if it is cancelable).
|
|
61
|
+
* @method
|
|
62
|
+
* @returns {null}
|
|
63
|
+
*/
|
|
64
|
+
preventDefault(): null;
|
|
65
|
+
/**
|
|
66
|
+
* For this particular event, no other listener will be called.
|
|
67
|
+
* Neither those attached on the same element, nor those attached on elements which will be traversed later (in
|
|
68
|
+
* capture phase, for instance)
|
|
69
|
+
* @method
|
|
70
|
+
* @returns {null}
|
|
71
|
+
*/
|
|
72
|
+
stopImmediatePropagation(): null;
|
|
73
|
+
/**
|
|
74
|
+
* Stops the propagation of events further along in the Dom.
|
|
75
|
+
* @method
|
|
76
|
+
* @returns {null}
|
|
77
|
+
*/
|
|
78
|
+
stopPropagation(): null;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM EventTarget Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { PseudoEvent } from './PseudoEvent';
|
|
7
|
+
export type listenerOptions = {
|
|
8
|
+
capture: boolean;
|
|
9
|
+
once: boolean;
|
|
10
|
+
passive: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Simulate the behaviour of the EventTarget Class when there is no DOM available.
|
|
14
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
15
|
+
* @interface
|
|
16
|
+
* @property {function} addEventListener
|
|
17
|
+
* @property {function} removeEventListener
|
|
18
|
+
* @property {function} dispatchEvent
|
|
19
|
+
*/
|
|
20
|
+
export interface PseudoEventTarget {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new EventTarget object instance.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Registers an event handler of a specific event type on the EventTarget.
|
|
26
|
+
* @param {string} type
|
|
27
|
+
* @param {function|Object} callback
|
|
28
|
+
* @param {boolean|Object} [useCapture=false]
|
|
29
|
+
*/
|
|
30
|
+
addEventListener(type: string, callback: Function | {
|
|
31
|
+
handleEvent: Function;
|
|
32
|
+
} | any, useCapture: listenerOptions | boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* Removes an event listener from the EventTarget.
|
|
35
|
+
* @param {string} type
|
|
36
|
+
* @param {function} callback
|
|
37
|
+
*/
|
|
38
|
+
removeEventListener(type: string, callback: Function): void;
|
|
39
|
+
/**
|
|
40
|
+
* Dispatches an event to this EventTarget.
|
|
41
|
+
* @param {Event|PseudoEvent} event
|
|
42
|
+
* @param {EventTarget|PseudoEventTarget} target
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
dispatchEvent(event: PseudoEvent, target: PseudoEventTarget): boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM HTMLElement Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { PseudoElement } from './PseudoElement';
|
|
7
|
+
/**
|
|
8
|
+
* Simulate the behaviour of the HTMLElement Class when there is no DOM available.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @class
|
|
11
|
+
* @augments PseudoElement
|
|
12
|
+
* @property {boolean} hidden - State of whether element is visible
|
|
13
|
+
* @property {number} offsetHeight - The height of the element as offset by the parent element
|
|
14
|
+
* @property {number} offsetLeft - The position of the left side of the element based on the parent element
|
|
15
|
+
* @property {PseudoHTMLElement} offsetParent - A reference to the closest positioned parent element
|
|
16
|
+
* @property {number} offsetTop - The position of the top side of the element based on the parent element
|
|
17
|
+
* @property {number} offsetWidth - The width of the element as offset by the parent element
|
|
18
|
+
* @property {Object} style - A container to define all applied inline-styles
|
|
19
|
+
* @property {string} title - The title attribute which affects the text visible on hover
|
|
20
|
+
*/
|
|
21
|
+
export interface PseudoHTMLElement extends PseudoElement {
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PseudoAttr } from './PseudoAttr';
|
|
2
|
+
export interface PseudoNamedNodeMap {
|
|
3
|
+
get length(): number;
|
|
4
|
+
getNamedItem(name: string): PseudoAttr | null;
|
|
5
|
+
setNamedItem(attr: PseudoAttr): PseudoAttr | null;
|
|
6
|
+
removeNamedItem(attrName: string): PseudoAttr;
|
|
7
|
+
item(index: number): PseudoAttr | null;
|
|
8
|
+
getNamedItemNS(namespace: string, localName: string): PseudoAttr | null;
|
|
9
|
+
setNamedItemNS(attr: PseudoAttr): PseudoAttr | null;
|
|
10
|
+
removeNamedItemNS(namespace: string, localName: string): PseudoAttr;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM Node Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
7
|
+
import { PseudoNodeList } from '../classes/PseudoNodeList';
|
|
8
|
+
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
9
|
+
import { PseudoDocument } from './PseudoDocument';
|
|
10
|
+
import { PseudoElement } from './PseudoElement';
|
|
11
|
+
import { PseudoDocumentFragment } from './PseudoDocumentFragment';
|
|
12
|
+
/**
|
|
13
|
+
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
14
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
15
|
+
* @class
|
|
16
|
+
* @augments PseudoEventTarget
|
|
17
|
+
* @property {string} name
|
|
18
|
+
* @property {function} appendChild
|
|
19
|
+
* @property {function} removeChild
|
|
20
|
+
*/
|
|
21
|
+
export interface PseudoNode extends PseudoEventTarget {
|
|
22
|
+
/**
|
|
23
|
+
* Returns a string representing the base URL of the document containing the Node.
|
|
24
|
+
*/
|
|
25
|
+
get baseURI(): Location | string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a live NodeList containing all the children of this node (including elements, text and comments). NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.
|
|
28
|
+
*/
|
|
29
|
+
get childNodes(): PseudoNodeList | LinkedTreeList;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a Node representing the first direct child node of the node, or null if the node has no child.
|
|
32
|
+
*/
|
|
33
|
+
get firstChild(): PseudoNode | null;
|
|
34
|
+
/**
|
|
35
|
+
* A boolean indicating whether or not the Node is connected (directly or indirectly) to the context object, e.g. the Document object in the case of the normal DOM, or the ShadowRoot in the case of a shadow DOM.
|
|
36
|
+
*/
|
|
37
|
+
get isConnected(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Returns a Node representing the last direct child node of the node, or null if the node has no child.
|
|
40
|
+
*/
|
|
41
|
+
get lastChild(): PseudoNode | null;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a Node representing the next node in the tree, or null if there isn't such node.
|
|
44
|
+
*/
|
|
45
|
+
get nextSibling(): PseudoNode | null;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a string containing the name of the Node. The structure of the name will differ with the node type. E.g. An HTMLElement will contain the name of the corresponding tag, like 'audio' for an HTMLAudioElement, a Text node will have the '#text' string, or a Document node will have the '#document' string.
|
|
48
|
+
*/
|
|
49
|
+
get nodeName(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an unsigned short representing the type of the node. Possible values are:
|
|
52
|
+
* ________________________________________
|
|
53
|
+
* | Name | Value |
|
|
54
|
+
* |----------------------------------------
|
|
55
|
+
* | ELEMENT_NODE | 1 |
|
|
56
|
+
* | ATTRIBUTE_NODE | 2 |
|
|
57
|
+
* | TEXT_NODE | 3 |
|
|
58
|
+
* | CDATA_SECTION_NODE | 4 |
|
|
59
|
+
* | PROCESSING_INSTRUCTION_NODE | 7 |
|
|
60
|
+
* | COMMENT_NODE | 8 |
|
|
61
|
+
* | DOCUMENT_NODE | 9 |
|
|
62
|
+
* | DOCUMENT_TYPE_NODE | 10 |
|
|
63
|
+
* | DOCUMENT_FRAGMENT_NODE | 11 |
|
|
64
|
+
*/
|
|
65
|
+
get nodeType(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the value of the current node.
|
|
68
|
+
*/
|
|
69
|
+
get nodeValue(): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the value of the current node.
|
|
72
|
+
* @param value
|
|
73
|
+
*/
|
|
74
|
+
set nodeValue(value: string | null);
|
|
75
|
+
/**
|
|
76
|
+
* Returns the Document that this node belongs to. If the node is itself a document, returns null.
|
|
77
|
+
*/
|
|
78
|
+
get ownerDocument(): PseudoDocument | null;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a Node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.
|
|
81
|
+
*/
|
|
82
|
+
get parentNode(): PseudoNode | null;
|
|
83
|
+
/**
|
|
84
|
+
* Returns an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.
|
|
85
|
+
*/
|
|
86
|
+
get parentElement(): PseudoElement | null;
|
|
87
|
+
/**
|
|
88
|
+
* Returns a Node representing the previous node in the tree, or null if there isn't such node.
|
|
89
|
+
*/
|
|
90
|
+
get previousSibling(): PseudoNode | null;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the textual content of an element and all its descendants.
|
|
93
|
+
*/
|
|
94
|
+
get textContent(): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the textual content of an element and all its descendants.
|
|
97
|
+
* @param text
|
|
98
|
+
*/
|
|
99
|
+
set textContent(text: string | null);
|
|
100
|
+
/**
|
|
101
|
+
* Adds the specified childNode argument as the last child to the current node. If the argument referenced an existing node on the DOM tree, the node will be detached from its current position and attached at the new position.
|
|
102
|
+
* @param {PseudoNode} childNode
|
|
103
|
+
* @returns {PseudoNode}
|
|
104
|
+
*/
|
|
105
|
+
appendChild(childNode: PseudoNode): PseudoNode;
|
|
106
|
+
/**
|
|
107
|
+
* Clone a Node, and optionally, all of its contents. By default, it clones the content of the node.
|
|
108
|
+
* @param deep
|
|
109
|
+
*/
|
|
110
|
+
cloneNode(deep: boolean): PseudoNode;
|
|
111
|
+
/**
|
|
112
|
+
* Compares the position of the current node against another node in any other document.
|
|
113
|
+
* @param otherNode
|
|
114
|
+
*/
|
|
115
|
+
compareDocumentPosition(otherNode: PseudoNode): number;
|
|
116
|
+
/**
|
|
117
|
+
* Returns true or false value indicating whether or not a node is a descendant of the calling node.
|
|
118
|
+
* @param otherNode
|
|
119
|
+
*/
|
|
120
|
+
contains(otherNode: PseudoNode): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Returns the context object's root which optionally includes the shadow root if it is available.
|
|
123
|
+
* @param options
|
|
124
|
+
*/
|
|
125
|
+
getRootNode(options: {
|
|
126
|
+
composed: boolean;
|
|
127
|
+
}): PseudoNode;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a boolean value indicating whether the element has any child nodes.
|
|
130
|
+
*/
|
|
131
|
+
hasChildNodes(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Inserts a Node before the reference node as a child of a specified parent node.
|
|
134
|
+
* @param newNode
|
|
135
|
+
* @param referenceNode
|
|
136
|
+
*/
|
|
137
|
+
insertBefore(newNode: PseudoNode, referenceNode: PseudoNode | null): PseudoNode | PseudoDocumentFragment;
|
|
138
|
+
/**
|
|
139
|
+
* Accepts a namespace URI as an argument and returns a boolean value with a value of true if the namespace is the default namespace on the given node or false if not.
|
|
140
|
+
* @param namespaceURI
|
|
141
|
+
*/
|
|
142
|
+
isDefaultNamespace(namespaceURI: string | null): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a boolean value which indicates whether two nodes are of the same type and all their defining data points match.
|
|
145
|
+
* @param otherNode
|
|
146
|
+
*/
|
|
147
|
+
isEqualNode(otherNode: PseudoNode): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Returns a boolean value indicating whether the two nodes are the same (that is, they reference the same object).
|
|
150
|
+
* @param otherNode
|
|
151
|
+
*/
|
|
152
|
+
isSameNode(otherNode: PseudoNode): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Returns a string containing the prefix for a given namespace URI, if present, and null if not. When multiple prefixes are possible, the result is implementation-dependent.
|
|
155
|
+
* @param namespace
|
|
156
|
+
*/
|
|
157
|
+
lookupPrefix(namespace: string): string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Accepts a prefix and returns the namespace URI associated with it on the given node if found (and null if not). Supplying null for the prefix will return the default namespace.
|
|
160
|
+
* @param prefix
|
|
161
|
+
*/
|
|
162
|
+
lookupNamespaceURI(prefix: string): string | null;
|
|
163
|
+
/**
|
|
164
|
+
* Clean up all the text nodes under this element (merge adjacent, remove empty).
|
|
165
|
+
*/
|
|
166
|
+
normalize(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Removes a child node from the current element, which must be a child of the current node.
|
|
169
|
+
* @param {PseudoNode} child
|
|
170
|
+
* @returns {PseudoNode}
|
|
171
|
+
*/
|
|
172
|
+
removeChild(child: PseudoNode): PseudoNode;
|
|
173
|
+
/**
|
|
174
|
+
* Replaces one child Node of the current one with the second one given in parameter.
|
|
175
|
+
* @param newChild
|
|
176
|
+
* @param oldChild
|
|
177
|
+
*/
|
|
178
|
+
replaceChild(newChild: PseudoNode, oldChild: PseudoNode): PseudoNode;
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file All of the Pseudo Dom Helper Objects functions for simulating parts of the DOM when running scripts in NodeJs.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventService as PseudoEvent } from './services/EventService';
|
|
7
|
+
import PseudoEventTarget from './services/EventTargetService';
|
|
8
|
+
import { NodeService as PseudoNode } from './services/NodeService';
|
|
9
|
+
import { ElementService as PseudoElement } from './services/ElementService';
|
|
10
|
+
import { HTMLElementService as PseudoHTMLElement } from './services/HTMLElementService';
|
|
11
|
+
import PseudoHTMLDocument from './classes/PseudoHTMLDocument';
|
|
12
|
+
import generateDocument from './factories/generateDocument';
|
|
13
|
+
/**
|
|
14
|
+
* All methods exported from this module are encapsulated within pseudoDom.
|
|
15
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
+
* @typedef {Object} pseudoDom
|
|
17
|
+
* @module pseudoDom/objects
|
|
18
|
+
*/
|
|
19
|
+
declare const pseudoDom: {
|
|
20
|
+
generateDocument: (root: Window | any, context?: object) => Window | PseudoEventTarget;
|
|
21
|
+
PseudoEvent: typeof PseudoEvent;
|
|
22
|
+
PseudoEventTarget: typeof PseudoEventTarget;
|
|
23
|
+
PseudoNode: typeof PseudoNode;
|
|
24
|
+
PseudoElement: typeof PseudoElement;
|
|
25
|
+
PseudoHTMLElement: typeof PseudoHTMLElement;
|
|
26
|
+
PseudoHTMLDocument: typeof PseudoHTMLDocument;
|
|
27
|
+
};
|
|
28
|
+
export { generateDocument, PseudoEvent, PseudoEventTarget, PseudoNode, PseudoElement, PseudoHTMLElement, PseudoHTMLDocument };
|
|
29
|
+
export default pseudoDom;
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file All of the Pseudo Dom Helper Objects functions for simulating parts of the DOM when running scripts in NodeJs.
|
|
5
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
9
|
+
return mod && mod.__esModule
|
|
10
|
+
? mod
|
|
11
|
+
: {
|
|
12
|
+
default: mod
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(exports, '__esModule', {
|
|
16
|
+
value: true
|
|
17
|
+
})
|
|
18
|
+
exports.PseudoHTMLDocument = exports.PseudoHTMLElement = exports.PseudoElement = exports.PseudoNode = exports.PseudoEventTarget = exports.PseudoEvent = exports.generateDocument = void 0
|
|
19
|
+
const EventService_1 = require('./services/EventService')
|
|
20
|
+
Object.defineProperty(exports, 'PseudoEvent', {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return EventService_1.EventService
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
const EventTargetService_1 = __importDefault(require('./services/EventTargetService'))
|
|
27
|
+
exports.PseudoEventTarget = EventTargetService_1.default
|
|
28
|
+
const NodeService_1 = require('./services/NodeService')
|
|
29
|
+
Object.defineProperty(exports, 'PseudoNode', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return NodeService_1.NodeService
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
const ElementService_1 = require('./services/ElementService')
|
|
36
|
+
Object.defineProperty(exports, 'PseudoElement', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return ElementService_1.ElementService
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
const HTMLElementService_1 = require('./services/HTMLElementService')
|
|
43
|
+
Object.defineProperty(exports, 'PseudoHTMLElement', {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return HTMLElementService_1.HTMLElementService
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
const PseudoHTMLDocument_1 = __importDefault(require('./classes/PseudoHTMLDocument'))
|
|
50
|
+
exports.PseudoHTMLDocument = PseudoHTMLDocument_1.default
|
|
51
|
+
const generateDocument_1 = __importDefault(require('./factories/generateDocument'))
|
|
52
|
+
exports.generateDocument = generateDocument_1.default
|
|
53
|
+
/**
|
|
54
|
+
* All methods exported from this module are encapsulated within pseudoDom.
|
|
55
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
56
|
+
* @typedef {Object} pseudoDom
|
|
57
|
+
* @module pseudoDom/objects
|
|
58
|
+
*/
|
|
59
|
+
const pseudoDom = {
|
|
60
|
+
generateDocument: generateDocument_1.default,
|
|
61
|
+
PseudoEvent: EventService_1.EventService,
|
|
62
|
+
PseudoEventTarget: EventTargetService_1.default,
|
|
63
|
+
PseudoNode: NodeService_1.NodeService,
|
|
64
|
+
PseudoElement: ElementService_1.ElementService,
|
|
65
|
+
PseudoHTMLElement: HTMLElementService_1.HTMLElementService,
|
|
66
|
+
PseudoHTMLDocument: PseudoHTMLDocument_1.default
|
|
67
|
+
}
|
|
68
|
+
exports.default = pseudoDom
|
|
69
|
+
if (void 0) {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
(void 0).pseudoDom = pseudoDom
|
|
72
|
+
} else if (typeof window !== 'undefined') {
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
window.pseudoDom = pseudoDom
|
|
75
|
+
}
|
package/dist/main.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PseudoHTMLDocument=exports.PseudoHTMLElement=exports.PseudoElement=exports.PseudoNode=exports.PseudoEventTarget=exports.PseudoEvent=exports.generateDocument=void 0;const EventService_1=require("./services/EventService");Object.defineProperty(exports,"PseudoEvent",{enumerable:!0,get:function(){return EventService_1.EventService}});const EventTargetService_1=__importDefault(require("./services/EventTargetService"));exports.PseudoEventTarget=EventTargetService_1.default;const NodeService_1=require("./services/NodeService");Object.defineProperty(exports,"PseudoNode",{enumerable:!0,get:function(){return NodeService_1.NodeService}});const ElementService_1=require("./services/ElementService");Object.defineProperty(exports,"PseudoElement",{enumerable:!0,get:function(){return ElementService_1.ElementService}});const HTMLElementService_1=require("./services/HTMLElementService");Object.defineProperty(exports,"PseudoHTMLElement",{enumerable:!0,get:function(){return HTMLElementService_1.HTMLElementService}});const PseudoHTMLDocument_1=__importDefault(require("./classes/PseudoHTMLDocument"));exports.PseudoHTMLDocument=PseudoHTMLDocument_1.default;const generateDocument_1=__importDefault(require("./factories/generateDocument"));exports.generateDocument=generateDocument_1.default;const pseudoDom={generateDocument:generateDocument_1.default,PseudoEvent:EventService_1.EventService,PseudoEventTarget:EventTargetService_1.default,PseudoNode:NodeService_1.NodeService,PseudoElement:ElementService_1.ElementService,PseudoHTMLElement:HTMLElementService_1.HTMLElementService,PseudoHTMLDocument:PseudoHTMLDocument_1.default};exports.default=pseudoDom,"undefined"!=typeof window&&(window.pseudoDom=pseudoDom);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule
|
|
5
|
+
? mod
|
|
6
|
+
: {
|
|
7
|
+
default: mod
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(exports, '__esModule', {
|
|
11
|
+
value: true
|
|
12
|
+
})
|
|
13
|
+
exports.AnimationService = void 0
|
|
14
|
+
const EventTargetService_1 = __importDefault(require('./EventTargetService'))
|
|
15
|
+
class AnimationService extends EventTargetService_1.default {}
|
|
16
|
+
exports.AnimationService = AnimationService
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AnimationService=void 0;const EventTargetService_1=__importDefault(require("./EventTargetService"));class AnimationService extends EventTargetService_1.default{}exports.AnimationService=AnimationService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PseudoAttr } from '../interfaces/PseudoAttr';
|
|
2
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
3
|
+
import { NodeService } from './NodeService';
|
|
4
|
+
/**
|
|
5
|
+
* Simulate the behaviour of the Attr Class when there is no DOM available.
|
|
6
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
7
|
+
* @class
|
|
8
|
+
* @augments NodeService
|
|
9
|
+
*/
|
|
10
|
+
export declare class AttrService extends NodeService implements PseudoAttr {
|
|
11
|
+
value: string;
|
|
12
|
+
private readonly attributeName;
|
|
13
|
+
private readonly element;
|
|
14
|
+
private readonly namespace;
|
|
15
|
+
private readonly namespacePrefix;
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} name The name of the attribute
|
|
18
|
+
* @param {string} [value=''] The value of the attribute
|
|
19
|
+
* @param {PseudoElement|null} [ownerElement=null] The element which has this attribute
|
|
20
|
+
* @param {string} [namespaceURI=''] The namespace of the attribute
|
|
21
|
+
* @param {string|null} [prefix=null] The namespace prefix of the attribute
|
|
22
|
+
* @constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(name?: string, value?: string, ownerElement?: PseudoElement | null, namespaceURI?: string, prefix?: string | null);
|
|
25
|
+
get nodeType(): number;
|
|
26
|
+
get localName(): string;
|
|
27
|
+
get name(): string;
|
|
28
|
+
get namespaceURI(): string;
|
|
29
|
+
get ownerElement(): PseudoElement | null;
|
|
30
|
+
get prefix(): string | null;
|
|
31
|
+
}
|