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,77 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.find.js')
|
|
5
|
+
Object.defineProperty(exports, '__esModule', {
|
|
6
|
+
value: true
|
|
7
|
+
})
|
|
8
|
+
exports.NamedNodeMapService = void 0
|
|
9
|
+
/**
|
|
10
|
+
* Simulate the behaviour of the NamedNodeMap Class when there is no DOM available.
|
|
11
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
+
* @class
|
|
13
|
+
*/
|
|
14
|
+
class NamedNodeMapService {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Array<PseudoAttr>} [attributes=[]] The attributes to start with
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
|
+
constructor (attributes = []) {
|
|
20
|
+
this.attributes = attributes.slice()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get length () {
|
|
24
|
+
return this.attributes.length
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getNamedItem (name) {
|
|
28
|
+
return this.attributes.find(attr => attr.name === name) || null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setNamedItem (attr) {
|
|
32
|
+
const index = this.attributes.findIndex(existing => existing.name === attr.name)
|
|
33
|
+
if (index < 0) {
|
|
34
|
+
this.attributes.push(attr)
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
const replaced = this.attributes[index]
|
|
38
|
+
this.attributes[index] = attr
|
|
39
|
+
return replaced
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
removeNamedItem (attrName) {
|
|
43
|
+
const index = this.attributes.findIndex(attr => attr.name === attrName)
|
|
44
|
+
if (index < 0) {
|
|
45
|
+
throw new Error(`The attribute "${attrName}" was not found.`)
|
|
46
|
+
}
|
|
47
|
+
return this.attributes.splice(index, 1)[0]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
item (index) {
|
|
51
|
+
return this.attributes[index] || null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getNamedItemNS (namespace, localName) {
|
|
55
|
+
return this.attributes.find(attr => attr.namespaceURI === namespace && attr.localName === localName) || null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setNamedItemNS (attr) {
|
|
59
|
+
const index = this.attributes.findIndex(existing => existing.namespaceURI === attr.namespaceURI && existing.localName === attr.localName)
|
|
60
|
+
if (index < 0) {
|
|
61
|
+
this.attributes.push(attr)
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
const replaced = this.attributes[index]
|
|
65
|
+
this.attributes[index] = attr
|
|
66
|
+
return replaced
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
removeNamedItemNS (namespace, localName) {
|
|
70
|
+
const index = this.attributes.findIndex(attr => attr.namespaceURI === namespace && attr.localName === localName)
|
|
71
|
+
if (index < 0) {
|
|
72
|
+
throw new Error(`The attribute "${localName}" in the namespace "${namespace}" was not found.`)
|
|
73
|
+
}
|
|
74
|
+
return this.attributes.splice(index, 1)[0]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.NamedNodeMapService = NamedNodeMapService
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.NamedNodeMapService=void 0;class NamedNodeMapService{constructor(t=[]){this.attributes=t.slice()}get length(){return this.attributes.length}getNamedItem(t){return this.attributes.find(e=>e.name===t)||null}setNamedItem(t){const e=this.attributes.findIndex(e=>e.name===t.name);if(e<0)return this.attributes.push(t),null;const r=this.attributes[e];return this.attributes[e]=t,r}removeNamedItem(t){const e=this.attributes.findIndex(e=>e.name===t);if(e<0)throw new Error(`The attribute "${t}" was not found.`);return this.attributes.splice(e,1)[0]}item(t){return this.attributes[t]||null}getNamedItemNS(t,e){return this.attributes.find(r=>r.namespaceURI===t&&r.localName===e)||null}setNamedItemNS(t){const e=this.attributes.findIndex(e=>e.namespaceURI===t.namespaceURI&&e.localName===t.localName);if(e<0)return this.attributes.push(t),null;const r=this.attributes[e];return this.attributes[e]=t,r}removeNamedItemNS(t,e){const r=this.attributes.findIndex(r=>r.namespaceURI===t&&r.localName===e);if(r<0)throw new Error(`The attribute "${e}" in the namespace "${t}" was not found.`);return this.attributes.splice(r,1)[0]}}exports.NamedNodeMapService=NamedNodeMapService;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PseudoNodeList } from '../classes/PseudoNodeList';
|
|
2
|
+
import { LinkedTreeList } from 'collect-your-stuff/dist/collections/linked-tree-list/LinkedTreeList';
|
|
3
|
+
import { PseudoNode } from '../interfaces/PseudoNode';
|
|
4
|
+
import EventTargetService from './EventTargetService';
|
|
5
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
6
|
+
import { PseudoDocument } from '../interfaces/PseudoDocument';
|
|
7
|
+
import { PseudoDocumentFragment } from '../interfaces/PseudoDocumentFragment';
|
|
8
|
+
/**
|
|
9
|
+
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
10
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
11
|
+
* @class
|
|
12
|
+
* @augments PseudoEventTarget
|
|
13
|
+
* @property {string} name
|
|
14
|
+
* @property {function} appendChild
|
|
15
|
+
* @property {function} removeChild
|
|
16
|
+
*/
|
|
17
|
+
export declare class NodeService extends EventTargetService implements PseudoNode {
|
|
18
|
+
static readonly DEFAULT_NODE = 0;
|
|
19
|
+
static readonly ELEMENT_NODE = 1;
|
|
20
|
+
static readonly ATTRIBUTE_NODE = 2;
|
|
21
|
+
static readonly TEXT_NODE = 3;
|
|
22
|
+
static readonly CDATA_SECTION_NODE = 4;
|
|
23
|
+
static readonly ENTITY_REFERENCE_NODE = 5;
|
|
24
|
+
static readonly ENTITY_NODE = 6;
|
|
25
|
+
static readonly PROCESSING_INSTRUCTION_NODE = 7;
|
|
26
|
+
static readonly COMMENT_NODE = 8;
|
|
27
|
+
static readonly DOCUMENT_NODE = 9;
|
|
28
|
+
static readonly DOCUMENT_TYPE_NODE = 10;
|
|
29
|
+
static readonly DOCUMENT_FRAGMENT_NODE = 11;
|
|
30
|
+
static readonly NOTATION_NODE = 12;
|
|
31
|
+
children: PseudoNodeList | LinkedTreeList;
|
|
32
|
+
parent: PseudoNode | null;
|
|
33
|
+
protected nodeNameValue: string;
|
|
34
|
+
private nodeValueStore;
|
|
35
|
+
private textContentStore;
|
|
36
|
+
private next;
|
|
37
|
+
private prev;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @constructor
|
|
41
|
+
*/
|
|
42
|
+
constructor();
|
|
43
|
+
get baseURI(): Location | string;
|
|
44
|
+
get childNodes(): PseudoNodeList | LinkedTreeList;
|
|
45
|
+
get firstChild(): PseudoNode | null;
|
|
46
|
+
get isConnected(): boolean;
|
|
47
|
+
get lastChild(): PseudoNode | null;
|
|
48
|
+
get nextSibling(): PseudoNode | null;
|
|
49
|
+
get nodeName(): string;
|
|
50
|
+
get nodeType(): number;
|
|
51
|
+
get nodeValue(): string | null;
|
|
52
|
+
set nodeValue(value: string | null);
|
|
53
|
+
get ownerDocument(): PseudoDocument | null;
|
|
54
|
+
get parentNode(): PseudoNode | null;
|
|
55
|
+
get parentElement(): PseudoElement | null;
|
|
56
|
+
get previousSibling(): PseudoNode | null;
|
|
57
|
+
get textContent(): string | null;
|
|
58
|
+
set textContent(text: string | null);
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {PseudoNode} childNode
|
|
62
|
+
* @returns {PseudoNode}
|
|
63
|
+
*/
|
|
64
|
+
appendChild(childNode: PseudoNode): PseudoNode;
|
|
65
|
+
/**
|
|
66
|
+
* Not implemented yet.
|
|
67
|
+
* @throws {Error}
|
|
68
|
+
*/
|
|
69
|
+
cloneNode(deep?: boolean): PseudoNode;
|
|
70
|
+
/**
|
|
71
|
+
* Not implemented yet.
|
|
72
|
+
* @throws {Error}
|
|
73
|
+
*/
|
|
74
|
+
compareDocumentPosition(otherNode: PseudoNode): number;
|
|
75
|
+
/**
|
|
76
|
+
* Not implemented yet.
|
|
77
|
+
* @throws {Error}
|
|
78
|
+
*/
|
|
79
|
+
contains(otherNode: PseudoNode): boolean;
|
|
80
|
+
getRootNode(options?: {
|
|
81
|
+
composed: boolean;
|
|
82
|
+
}): PseudoNode;
|
|
83
|
+
hasChildNodes(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Not implemented yet.
|
|
86
|
+
* @throws {Error}
|
|
87
|
+
*/
|
|
88
|
+
insertBefore(newNode: PseudoNode, referenceNode: PseudoNode | null): PseudoNode | PseudoDocumentFragment;
|
|
89
|
+
isDefaultNamespace(namespaceURI: string | null): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Not implemented yet.
|
|
92
|
+
* @throws {Error}
|
|
93
|
+
*/
|
|
94
|
+
isEqualNode(otherNode: PseudoNode): boolean;
|
|
95
|
+
isSameNode(otherNode: PseudoNode): boolean;
|
|
96
|
+
lookupPrefix(namespace: string): string | null;
|
|
97
|
+
lookupNamespaceURI(prefix: string): string | null;
|
|
98
|
+
normalize(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Remove the given child from this node.
|
|
101
|
+
* @param {PseudoNode} childElement The child node, or its TreeLinker from the children list
|
|
102
|
+
* @returns {PseudoNode}
|
|
103
|
+
* @throws {Error} When the node is not a child of this node
|
|
104
|
+
*/
|
|
105
|
+
removeChild(childElement: PseudoNode): PseudoNode;
|
|
106
|
+
/**
|
|
107
|
+
* Not implemented yet.
|
|
108
|
+
* @throws {Error}
|
|
109
|
+
*/
|
|
110
|
+
replaceChild(newChild: PseudoNode, oldChild: PseudoNode): PseudoNode;
|
|
111
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.iterator.constructor.js')
|
|
4
|
+
require('core-js/modules/esnext.iterator.for-each.js')
|
|
5
|
+
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
6
|
+
return mod && mod.__esModule
|
|
7
|
+
? mod
|
|
8
|
+
: {
|
|
9
|
+
default: mod
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
})
|
|
15
|
+
exports.NodeService = void 0
|
|
16
|
+
/**
|
|
17
|
+
* @file Substitute for the DOM Node Class.
|
|
18
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
19
|
+
* @version 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
const generateNodeList_1 = __importDefault(require('../factories/generateNodeList'))
|
|
22
|
+
const EventTargetService_1 = __importDefault(require('./EventTargetService'))
|
|
23
|
+
/**
|
|
24
|
+
* Simulate the behaviour of the Node Class when there is no DOM available.
|
|
25
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
26
|
+
* @class
|
|
27
|
+
* @augments PseudoEventTarget
|
|
28
|
+
* @property {string} name
|
|
29
|
+
* @property {function} appendChild
|
|
30
|
+
* @property {function} removeChild
|
|
31
|
+
*/
|
|
32
|
+
class NodeService extends EventTargetService_1.default {
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @constructor
|
|
36
|
+
*/
|
|
37
|
+
constructor () {
|
|
38
|
+
super()
|
|
39
|
+
this.nodeValueStore = ''
|
|
40
|
+
this.textContentStore = ''
|
|
41
|
+
this.nodeNameValue = ''
|
|
42
|
+
this.children = (0, generateNodeList_1.default)()
|
|
43
|
+
this.parent = null
|
|
44
|
+
this.next = null
|
|
45
|
+
this.prev = null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get baseURI () {
|
|
49
|
+
return window.location || '/'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get childNodes () {
|
|
53
|
+
return this.children
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get firstChild () {
|
|
57
|
+
return this.children.first ? this.children.first.data : null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get isConnected () {
|
|
61
|
+
return !!this.parent
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get lastChild () {
|
|
65
|
+
return this.children.last ? this.children.last.data : null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get nextSibling () {
|
|
69
|
+
return this.isConnected ? this.next : null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get nodeName () {
|
|
73
|
+
return this.nodeNameValue || ''
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get nodeType () {
|
|
77
|
+
return NodeService.DEFAULT_NODE
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get nodeValue () {
|
|
81
|
+
return this.nodeValueStore
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set nodeValue (value) {
|
|
85
|
+
this.nodeValueStore = value
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get ownerDocument () {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get parentNode () {
|
|
93
|
+
return this.parent
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get parentElement () {
|
|
97
|
+
return this.parent && this.parent.nodeType === NodeService.ELEMENT_NODE ? this.parent : null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get previousSibling () {
|
|
101
|
+
return this.isConnected ? this.prev : null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get textContent () {
|
|
105
|
+
return this.textContentStore
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
set textContent (text) {
|
|
109
|
+
this.textContentStore = text
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {PseudoNode} childNode
|
|
115
|
+
* @returns {PseudoNode}
|
|
116
|
+
*/
|
|
117
|
+
appendChild (childNode) {
|
|
118
|
+
this.children.append(childNode)
|
|
119
|
+
return childNode
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Not implemented yet.
|
|
124
|
+
* @throws {Error}
|
|
125
|
+
*/
|
|
126
|
+
cloneNode (deep = false) {
|
|
127
|
+
throw new Error(`NodeService.cloneNode(${deep}) is not implemented yet.`)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Not implemented yet.
|
|
132
|
+
* @throws {Error}
|
|
133
|
+
*/
|
|
134
|
+
compareDocumentPosition (otherNode) {
|
|
135
|
+
throw new Error('NodeService.compareDocumentPosition() is not implemented yet.')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Not implemented yet.
|
|
140
|
+
* @throws {Error}
|
|
141
|
+
*/
|
|
142
|
+
contains (otherNode) {
|
|
143
|
+
throw new Error('NodeService.contains() is not implemented yet.')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
getRootNode (options = {
|
|
147
|
+
composed: false
|
|
148
|
+
}) {
|
|
149
|
+
return this.parent ? this.parent.getRootNode(options) : this
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
hasChildNodes () {
|
|
153
|
+
return this.children.length > 0
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Not implemented yet.
|
|
158
|
+
* @throws {Error}
|
|
159
|
+
*/
|
|
160
|
+
insertBefore (newNode, referenceNode) {
|
|
161
|
+
throw new Error('NodeService.insertBefore() is not implemented yet.')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
isDefaultNamespace (namespaceURI) {
|
|
165
|
+
return namespaceURI === null
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Not implemented yet.
|
|
170
|
+
* @throws {Error}
|
|
171
|
+
*/
|
|
172
|
+
isEqualNode (otherNode) {
|
|
173
|
+
throw new Error('NodeService.isEqualNode() is not implemented yet.')
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
isSameNode (otherNode) {
|
|
177
|
+
return this === otherNode
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
lookupPrefix (namespace) {
|
|
181
|
+
return null
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
lookupNamespaceURI (prefix) {
|
|
185
|
+
return null
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
normalize () {}
|
|
189
|
+
/**
|
|
190
|
+
* Remove the given child from this node.
|
|
191
|
+
* @param {PseudoNode} childElement The child node, or its TreeLinker from the children list
|
|
192
|
+
* @returns {PseudoNode}
|
|
193
|
+
* @throws {Error} When the node is not a child of this node
|
|
194
|
+
*/
|
|
195
|
+
removeChild (childElement) {
|
|
196
|
+
let found = null
|
|
197
|
+
this.children.forEach(linker => {
|
|
198
|
+
if (found === null && (linker === childElement || linker.data === childElement)) {
|
|
199
|
+
found = linker
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
if (found === null) {
|
|
203
|
+
throw new Error('The node to be removed is not a child of this node.')
|
|
204
|
+
}
|
|
205
|
+
this.children.remove(found)
|
|
206
|
+
return found.data
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Not implemented yet.
|
|
211
|
+
* @throws {Error}
|
|
212
|
+
*/
|
|
213
|
+
replaceChild (newChild, oldChild) {
|
|
214
|
+
throw new Error('NodeService.replaceChild() is not implemented yet.')
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.NodeService = NodeService
|
|
218
|
+
NodeService.DEFAULT_NODE = 0
|
|
219
|
+
NodeService.ELEMENT_NODE = 1
|
|
220
|
+
NodeService.ATTRIBUTE_NODE = 2
|
|
221
|
+
NodeService.TEXT_NODE = 3
|
|
222
|
+
NodeService.CDATA_SECTION_NODE = 4
|
|
223
|
+
NodeService.ENTITY_REFERENCE_NODE = 5
|
|
224
|
+
NodeService.ENTITY_NODE = 6
|
|
225
|
+
NodeService.PROCESSING_INSTRUCTION_NODE = 7
|
|
226
|
+
NodeService.COMMENT_NODE = 8
|
|
227
|
+
NodeService.DOCUMENT_NODE = 9
|
|
228
|
+
NodeService.DOCUMENT_TYPE_NODE = 10
|
|
229
|
+
NodeService.DOCUMENT_FRAGMENT_NODE = 11
|
|
230
|
+
NodeService.NOTATION_NODE = 12
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.for-each.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.NodeService=void 0;const generateNodeList_1=__importDefault(require("../factories/generateNodeList")),EventTargetService_1=__importDefault(require("./EventTargetService"));class NodeService extends EventTargetService_1.default{constructor(){super(),this.nodeValueStore="",this.textContentStore="",this.nodeNameValue="",this.children=(0,generateNodeList_1.default)(),this.parent=null,this.next=null,this.prev=null}get baseURI(){return window.location||"/"}get childNodes(){return this.children}get firstChild(){return this.children.first?this.children.first.data:null}get isConnected(){return!!this.parent}get lastChild(){return this.children.last?this.children.last.data:null}get nextSibling(){return this.isConnected?this.next:null}get nodeName(){return this.nodeNameValue||""}get nodeType(){return NodeService.DEFAULT_NODE}get nodeValue(){return this.nodeValueStore}set nodeValue(e){this.nodeValueStore=e}get ownerDocument(){return null}get parentNode(){return this.parent}get parentElement(){return this.parent&&this.parent.nodeType===NodeService.ELEMENT_NODE?this.parent:null}get previousSibling(){return this.isConnected?this.prev:null}get textContent(){return this.textContentStore}set textContent(e){this.textContentStore=e}appendChild(e){return this.children.append(e),e}cloneNode(e=!1){throw new Error(`NodeService.cloneNode(${e}) is not implemented yet.`)}compareDocumentPosition(e){throw new Error("NodeService.compareDocumentPosition() is not implemented yet.")}contains(e){throw new Error("NodeService.contains() is not implemented yet.")}getRootNode(e={composed:!1}){return this.parent?this.parent.getRootNode(e):this}hasChildNodes(){return this.children.length>0}insertBefore(e,t){throw new Error("NodeService.insertBefore() is not implemented yet.")}isDefaultNamespace(e){return null===e}isEqualNode(e){throw new Error("NodeService.isEqualNode() is not implemented yet.")}isSameNode(e){return this===e}lookupPrefix(e){return null}lookupNamespaceURI(e){return null}normalize(){}removeChild(e){let t=null;if(this.children.forEach(r=>{null!==t||r!==e&&r.data!==e||(t=r)}),null===t)throw new Error("The node to be removed is not a child of this node.");return this.children.remove(t),t.data}replaceChild(e,t){throw new Error("NodeService.replaceChild() is not implemented yet.")}}exports.NodeService=NodeService,NodeService.DEFAULT_NODE=0,NodeService.ELEMENT_NODE=1,NodeService.ATTRIBUTE_NODE=2,NodeService.TEXT_NODE=3,NodeService.CDATA_SECTION_NODE=4,NodeService.ENTITY_REFERENCE_NODE=5,NodeService.ENTITY_NODE=6,NodeService.PROCESSING_INSTRUCTION_NODE=7,NodeService.COMMENT_NODE=8,NodeService.DOCUMENT_NODE=9,NodeService.DOCUMENT_TYPE_NODE=10,NodeService.DOCUMENT_FRAGMENT_NODE=11,NodeService.NOTATION_NODE=12;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.ShadowRootService = void 0
|
|
7
|
+
const DocumentFragmentService_1 = require('./DocumentFragmentService')
|
|
8
|
+
class ShadowRootService extends DocumentFragmentService_1.DocumentFragmentService {}
|
|
9
|
+
exports.ShadowRootService = ShadowRootService
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShadowRootService=void 0;const DocumentFragmentService_1=require("./DocumentFragmentService");class ShadowRootService extends DocumentFragmentService_1.DocumentFragmentService{}exports.ShadowRootService=ShadowRootService;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pseudo-dom",
|
|
3
|
+
"description": "Mock the DOM on the server side for managing state and testing",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "dist/main.js",
|
|
6
|
+
"types": "dist/main.d.ts",
|
|
7
|
+
"author": "Joshua Heagle",
|
|
8
|
+
"license": "GPL-3.0-only",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "gulp build",
|
|
11
|
+
"dev": "gulp",
|
|
12
|
+
"htmldocs": "jsdoc -R MAIN.md -r src/ -d docs",
|
|
13
|
+
"readme": "gulp readme",
|
|
14
|
+
"test": "gulp testFull",
|
|
15
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
16
|
+
"test:quick": "gulp testQuick",
|
|
17
|
+
"watch": "gulp watchFull",
|
|
18
|
+
"watch:test": "gulp watchTest"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"collect-your-stuff": "^1.2.8",
|
|
22
|
+
"core-js": "^3.50.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"js-build-tools": "^5.0.0",
|
|
26
|
+
"jsdoc": "^4.0.5",
|
|
27
|
+
"standard": "^17.1.2",
|
|
28
|
+
"test-filesystem": "^1.5.1"
|
|
29
|
+
},
|
|
30
|
+
"directories": {
|
|
31
|
+
"doc": "docs"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/jheagle/pseudo-dom.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/jheagle/pseudo-dom/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/jheagle/pseudo-dom#readme",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"dom",
|
|
43
|
+
"mock",
|
|
44
|
+
"pseudo-dom",
|
|
45
|
+
"testing",
|
|
46
|
+
"node",
|
|
47
|
+
"typescript"
|
|
48
|
+
],
|
|
49
|
+
"standard": {
|
|
50
|
+
"env": [
|
|
51
|
+
"jest"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist",
|
|
56
|
+
"browser"
|
|
57
|
+
]
|
|
58
|
+
}
|