pseudo-dom 0.17.0 → 1.0.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 +63 -5869
- package/browser/pseudo-dom.js +14889 -15288
- package/dist/classes/PseudoEventListener.d.ts +11 -37
- package/dist/classes/PseudoEventListener.js +11 -37
- package/dist/classes/PseudoHTMLDocument.d.ts +4 -12
- package/dist/classes/PseudoHTMLDocument.js +1 -11
- package/dist/classes/PseudoNodeList.d.ts +1 -9
- package/dist/classes/PseudoNodeList.js +1 -9
- package/dist/factories/createDataset.d.ts +1 -3
- package/dist/factories/createDataset.js +3 -8
- package/dist/factories/createEvent.d.ts +5 -9
- package/dist/factories/createEvent.js +3 -5
- package/dist/factories/createStyleDeclaration.d.ts +4 -10
- package/dist/factories/createStyleDeclaration.js +4 -10
- package/dist/factories/cssSelectAdapter.d.ts +0 -2
- package/dist/factories/cssSelectAdapter.js +3 -8
- package/dist/factories/eventDefaults.d.ts +5 -9
- package/dist/factories/eventDefaults.js +1 -4
- package/dist/factories/generateDocument.d.ts +2 -4
- package/dist/factories/generateDocument.js +2 -13
- package/dist/factories/generateNodeList.d.ts +1 -2
- package/dist/factories/generateNodeList.js +1 -2
- package/dist/factories/installGlobal.d.ts +2 -3
- package/dist/factories/installGlobal.js +3 -6
- package/dist/factories/logElement.d.ts +2 -4
- package/dist/factories/logElement.js +3 -7
- package/dist/factories/parseHTML.d.ts +3 -5
- package/dist/factories/parseHTML.js +4 -8
- package/dist/factories/query.d.ts +8 -16
- package/dist/factories/query.js +9 -19
- package/dist/factories/serializeHTML.d.ts +4 -10
- package/dist/factories/serializeHTML.js +12 -25
- package/dist/functions/activeElement.d.ts +3 -6
- package/dist/functions/activeElement.js +3 -6
- package/dist/functions/getElementById.d.ts +2 -4
- package/dist/functions/getElementById.js +2 -4
- package/dist/functions/getParentNodes.d.ts +1 -3
- package/dist/functions/getParentNodes.js +1 -3
- package/dist/functions/getParentNodesFromAttribute.d.ts +3 -5
- package/dist/functions/getParentNodesFromAttribute.js +3 -5
- package/dist/functions/modifierState.d.ts +3 -12
- package/dist/functions/modifierState.js +3 -7
- package/dist/interfaces/PseudoCSSStyleDeclaration.d.ts +1 -1
- package/dist/interfaces/PseudoDocument.d.ts +4 -9
- package/dist/interfaces/PseudoDocumentFragment.d.ts +1 -2
- package/dist/interfaces/PseudoElement.d.ts +39 -78
- package/dist/interfaces/PseudoEvent.d.ts +11 -43
- package/dist/interfaces/PseudoEvent.js +1 -3
- package/dist/interfaces/PseudoEventTarget.d.ts +7 -16
- package/dist/interfaces/PseudoHTMLCollection.d.ts +2 -4
- package/dist/interfaces/PseudoHTMLElement.d.ts +8 -13
- package/dist/interfaces/PseudoNode.d.ts +3 -13
- package/dist/main.d.ts +1 -6
- package/dist/main.js +1 -6
- package/dist/services/AttrService.d.ts +5 -9
- package/dist/services/AttrService.js +5 -9
- package/dist/services/CSSStyleDeclarationService.d.ts +10 -23
- package/dist/services/CSSStyleDeclarationService.js +10 -23
- package/dist/services/CustomEventService.d.ts +4 -15
- package/dist/services/CustomEventService.js +3 -10
- package/dist/services/DOMTokenListService.d.ts +2 -5
- package/dist/services/DOMTokenListService.js +2 -5
- package/dist/services/DocumentFragmentService.d.ts +1 -5
- package/dist/services/DocumentFragmentService.js +1 -5
- package/dist/services/DocumentService.d.ts +4 -12
- package/dist/services/DocumentService.js +4 -12
- package/dist/services/ElementService.d.ts +62 -120
- package/dist/services/ElementService.js +61 -117
- package/dist/services/EventService.d.ts +6 -44
- package/dist/services/EventService.js +18 -44
- package/dist/services/EventTargetService.d.ts +16 -28
- package/dist/services/EventTargetService.js +16 -28
- package/dist/services/FocusEventService.d.ts +4 -12
- package/dist/services/FocusEventService.js +3 -10
- package/dist/services/HTMLCollectionService.d.ts +6 -16
- package/dist/services/HTMLCollectionService.js +6 -16
- package/dist/services/HTMLElementService.d.ts +132 -154
- package/dist/services/HTMLElementService.js +333 -353
- package/dist/services/InputEventService.d.ts +5 -16
- package/dist/services/InputEventService.js +3 -12
- package/dist/services/KeyboardEventService.d.ts +8 -26
- package/dist/services/KeyboardEventService.js +4 -16
- package/dist/services/MouseEventService.d.ts +7 -30
- package/dist/services/MouseEventService.js +4 -18
- package/dist/services/NamedNodeMapService.d.ts +1 -4
- package/dist/services/NamedNodeMapService.js +1 -4
- package/dist/services/NodeService.d.ts +38 -69
- package/dist/services/NodeService.js +39 -72
- package/dist/services/PointerEventService.d.ts +4 -22
- package/dist/services/PointerEventService.js +3 -15
- package/dist/services/ShadowRootService.d.ts +0 -3
- package/dist/services/ShadowRootService.js +0 -3
- package/dist/services/UIEventService.d.ts +5 -17
- package/dist/services/UIEventService.js +3 -11
- package/dist/simulate.d.ts +7 -9
- package/dist/simulate.js +9 -15
- package/package.json +8 -7
|
@@ -4,32 +4,27 @@ import { PseudoDocumentFragment } from './PseudoDocumentFragment';
|
|
|
4
4
|
export interface PseudoDocument extends PseudoNode {
|
|
5
5
|
/**
|
|
6
6
|
* The first element, in tree order, whose id matches the given value, or null when there is none.
|
|
7
|
-
* @param
|
|
8
|
-
* @returns {PseudoElement|null}
|
|
7
|
+
* @param id
|
|
9
8
|
*/
|
|
10
9
|
getElementById(id: string): PseudoElement | null;
|
|
11
10
|
/**
|
|
12
11
|
* Make an element of the given type which belongs to this document but is not added anywhere until it is appended.
|
|
13
|
-
* @param
|
|
14
|
-
* @returns {PseudoElement}
|
|
12
|
+
* @param tagName The type of element to create
|
|
15
13
|
*/
|
|
16
14
|
createElement(tagName: string): PseudoElement;
|
|
17
15
|
/**
|
|
18
16
|
* Make a text node which belongs to this document.
|
|
19
|
-
* @param
|
|
20
|
-
* @returns {PseudoNode}
|
|
17
|
+
* @param data The text
|
|
21
18
|
*/
|
|
22
19
|
createTextNode(data: string): PseudoNode;
|
|
23
20
|
/**
|
|
24
21
|
* Make a comment which belongs to this document.
|
|
25
|
-
* @param
|
|
26
|
-
* @returns {PseudoNode}
|
|
22
|
+
* @param data The comment
|
|
27
23
|
*/
|
|
28
24
|
createComment(data: string): PseudoNode;
|
|
29
25
|
/**
|
|
30
26
|
* Make an empty document fragment which belongs to this document, a container for nodes which can be built up and
|
|
31
27
|
* then inserted in one go.
|
|
32
|
-
* @returns {PseudoDocumentFragment}
|
|
33
28
|
*/
|
|
34
29
|
createDocumentFragment(): PseudoDocumentFragment;
|
|
35
30
|
}
|
|
@@ -3,8 +3,7 @@ import { PseudoElement } from './PseudoElement';
|
|
|
3
3
|
export interface PseudoDocumentFragment extends PseudoNode {
|
|
4
4
|
/**
|
|
5
5
|
* The first element, in tree order, whose id matches the given value, or null when there is none.
|
|
6
|
-
* @param
|
|
7
|
-
* @returns {PseudoElement|null}
|
|
6
|
+
* @param id
|
|
8
7
|
*/
|
|
9
8
|
getElementById(id: string): PseudoElement | null;
|
|
10
9
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM Element Class.
|
|
5
3
|
*/
|
|
6
4
|
import { PseudoNode } from './PseudoNode';
|
|
7
5
|
import { PseudoHTMLSlotElement } from './PseudoHTMLSlotElement';
|
|
@@ -13,18 +11,6 @@ import { PseudoAnimation } from './PseudoAnimation';
|
|
|
13
11
|
import { PseudoAttr } from './PseudoAttr';
|
|
14
12
|
/**
|
|
15
13
|
* Simulate the behaviour of the Element Class when there is no DOM available.
|
|
16
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
17
|
-
* @class
|
|
18
|
-
* @augments PseudoNode
|
|
19
|
-
* @property {string} tagName
|
|
20
|
-
* @property {string} className
|
|
21
|
-
* @property {string} id
|
|
22
|
-
* @property {string} innerHtml
|
|
23
|
-
* @property {Array} attributes
|
|
24
|
-
* @property {function} hasAttribute
|
|
25
|
-
* @property {function} setAttribute
|
|
26
|
-
* @property {function} getAttribute
|
|
27
|
-
* @property {function} removeAttribute
|
|
28
14
|
*/
|
|
29
15
|
export interface PseudoElement extends PseudoNode {
|
|
30
16
|
/**
|
|
@@ -492,8 +478,7 @@ export interface PseudoElement extends PseudoNode {
|
|
|
492
478
|
/**
|
|
493
479
|
* Attaches a shadow DOM tree to the specified element and returns a reference to its ShadowRoot. Throws when the
|
|
494
480
|
* element already hosts one.
|
|
495
|
-
* @param
|
|
496
|
-
* @returns {PseudoShadowRoot}
|
|
481
|
+
* @param options
|
|
497
482
|
*/
|
|
498
483
|
attachShadow(options: {
|
|
499
484
|
mode: string;
|
|
@@ -506,19 +491,16 @@ export interface PseudoElement extends PseudoNode {
|
|
|
506
491
|
/**
|
|
507
492
|
* Returns whether an element is expected to be visible or not. Settable directly (boundingClientRect / isVisible /
|
|
508
493
|
* etc.) rather than really computed - there is no layout engine here.
|
|
509
|
-
* @returns {boolean}
|
|
510
494
|
*/
|
|
511
495
|
checkVisibility(): boolean;
|
|
512
496
|
/**
|
|
513
497
|
* Returns the Element which is the closest ancestor of the current element (or the current element itself) which matches the selectors given in parameter.
|
|
514
|
-
* @param
|
|
515
|
-
* @returns {PseudoElement|null}
|
|
498
|
+
* @param selectors A CSS selector
|
|
516
499
|
*/
|
|
517
500
|
closest(selectors: string): PseudoElement | null;
|
|
518
501
|
/**
|
|
519
502
|
* Returns a read-only view of the element's own inline style declarations (there is no CSS cascade here, so this
|
|
520
503
|
* is not a real computed style).
|
|
521
|
-
* @returns {{get: function(string): (string|undefined)}}
|
|
522
504
|
*/
|
|
523
505
|
computedStyleMap(): {
|
|
524
506
|
get: (property: string) => string | undefined;
|
|
@@ -526,7 +508,6 @@ export interface PseudoElement extends PseudoNode {
|
|
|
526
508
|
/**
|
|
527
509
|
* Returns an array of Animation objects currently active on the element. Settable directly (animations) - there is
|
|
528
510
|
* no animation engine here.
|
|
529
|
-
* @returns {Array<*>}
|
|
530
511
|
*/
|
|
531
512
|
getAnimations(): Array<any>;
|
|
532
513
|
/**
|
|
@@ -535,7 +516,6 @@ export interface PseudoElement extends PseudoNode {
|
|
|
535
516
|
getAttribute(attributeName: string): string | null;
|
|
536
517
|
/**
|
|
537
518
|
* Returns an array of attribute names from the current element.
|
|
538
|
-
* @returns {Array<string>}
|
|
539
519
|
*/
|
|
540
520
|
getAttributeNames(): Array<string>;
|
|
541
521
|
/**
|
|
@@ -546,22 +526,21 @@ export interface PseudoElement extends PseudoNode {
|
|
|
546
526
|
* Retrieves the node representation of the attribute with the specified name and namespace, from the current
|
|
547
527
|
* node and returns it as an Attr. There is no real namespace parsing here, so this ignores the namespace and
|
|
548
528
|
* behaves exactly like getAttributeNode.
|
|
549
|
-
* @param
|
|
550
|
-
* @param
|
|
529
|
+
* @param namespace Ignored
|
|
530
|
+
* @param attributeName
|
|
551
531
|
*/
|
|
552
532
|
getAttributeNodeNS(namespace: string, attributeName: string): PseudoAttr | null;
|
|
553
533
|
/**
|
|
554
534
|
* Retrieves the value of the attribute with the specified namespace and name from the current node and returns
|
|
555
535
|
* it as a string. There is no real namespace parsing here, so this ignores the namespace and behaves exactly
|
|
556
536
|
* like getAttribute.
|
|
557
|
-
* @param
|
|
558
|
-
* @param
|
|
537
|
+
* @param namespace Ignored
|
|
538
|
+
* @param attributeName
|
|
559
539
|
*/
|
|
560
540
|
getAttributeNS(namespace: string, attributeName: string): string | null;
|
|
561
541
|
/**
|
|
562
542
|
* Returns the size of an element and its position relative to the viewport. Settable directly
|
|
563
543
|
* (boundingClientRect) rather than really computed - there is no layout engine here.
|
|
564
|
-
* @returns {{x: number, y: number, width: number, height: number, top: number, right: number, bottom: number, left: number}}
|
|
565
544
|
*/
|
|
566
545
|
getBoundingClientRect(): {
|
|
567
546
|
x: number;
|
|
@@ -576,28 +555,24 @@ export interface PseudoElement extends PseudoNode {
|
|
|
576
555
|
/**
|
|
577
556
|
* Returns a collection of rectangles that indicate the bounding rectangles for each line of text in a client.
|
|
578
557
|
* Settable directly (clientRects) rather than really computed - there is no layout engine here.
|
|
579
|
-
* @returns {Array<*>}
|
|
580
558
|
*/
|
|
581
559
|
getClientRects(): Array<any>;
|
|
582
560
|
/**
|
|
583
561
|
* Returns a live HTMLCollection that contains all descendants of the current element that possess the list of classes given in the parameter.
|
|
584
|
-
* @param
|
|
585
|
-
* @returns {PseudoHTMLCollection}
|
|
562
|
+
* @param className One or more space separated classes
|
|
586
563
|
*/
|
|
587
564
|
getElementsByClassName(className: string): PseudoHTMLCollection;
|
|
588
565
|
/**
|
|
589
566
|
* Returns a live HTMLCollection containing all descendant elements, of a particular tag name, from the current element.
|
|
590
|
-
* @param
|
|
591
|
-
* @returns {PseudoHTMLCollection}
|
|
567
|
+
* @param tagName A tag name, or * for every element
|
|
592
568
|
*/
|
|
593
569
|
getElementsByTagName(tagName: string): PseudoHTMLCollection;
|
|
594
570
|
/**
|
|
595
571
|
* Returns a live HTMLCollection containing all descendant elements, of a particular tag name, from the current
|
|
596
572
|
* element. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like
|
|
597
573
|
* getElementsByTagName.
|
|
598
|
-
* @param
|
|
599
|
-
* @param
|
|
600
|
-
* @returns {PseudoHTMLCollection}
|
|
574
|
+
* @param namespace Ignored
|
|
575
|
+
* @param tagName
|
|
601
576
|
*/
|
|
602
577
|
getElementsByTagNameNS(namespace: string, tagName: string): PseudoHTMLCollection;
|
|
603
578
|
/**
|
|
@@ -608,45 +583,42 @@ export interface PseudoElement extends PseudoNode {
|
|
|
608
583
|
* Returns a boolean value indicating if the element has the specified attribute, in the specified namespace, or
|
|
609
584
|
* not. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like
|
|
610
585
|
* hasAttribute.
|
|
611
|
-
* @param
|
|
612
|
-
* @param
|
|
586
|
+
* @param namespace Ignored
|
|
587
|
+
* @param attributeName
|
|
613
588
|
*/
|
|
614
589
|
hasAttributeNS(namespace: string, attributeName: string): boolean;
|
|
615
590
|
/**
|
|
616
591
|
* Returns a boolean value indicating if the element has one or more HTML attributes present.
|
|
617
|
-
* @returns {boolean}
|
|
618
592
|
*/
|
|
619
593
|
hasAttributes(): boolean;
|
|
620
594
|
/**
|
|
621
595
|
* Indicates whether the element on which it is invoked has pointer capture for the pointer identified by the given pointer ID.
|
|
622
|
-
* @param
|
|
623
|
-
* @returns {boolean}
|
|
596
|
+
* @param pointerId
|
|
624
597
|
*/
|
|
625
598
|
hasPointerCapture(pointerId: number): boolean;
|
|
626
599
|
/**
|
|
627
600
|
* Inserts a given element at a given position relative to the element it is invoked upon.
|
|
628
|
-
* @param
|
|
629
|
-
* @param
|
|
630
|
-
* @returns
|
|
601
|
+
* @param position beforebegin, afterbegin, beforeend or afterend
|
|
602
|
+
* @param element The element to insert
|
|
603
|
+
* @returns The inserted element, or null when the position needs a parent this element does not have
|
|
631
604
|
*/
|
|
632
605
|
insertAdjacentElement(position: string, element: PseudoElement): PseudoElement | null;
|
|
633
606
|
/**
|
|
634
607
|
* Parses the text as HTML and inserts the resulting nodes into the tree in the position given.
|
|
635
|
-
* @param
|
|
636
|
-
* @param
|
|
608
|
+
* @param position beforebegin, afterbegin, beforeend or afterend
|
|
609
|
+
* @param text The markup to parse
|
|
637
610
|
* @throws {Error} When the position is not one of the four above
|
|
638
611
|
*/
|
|
639
612
|
insertAdjacentHTML(position: string, text: string): void;
|
|
640
613
|
/**
|
|
641
614
|
* Inserts a given text at a given position relative to the element it is invoked upon.
|
|
642
|
-
* @param
|
|
643
|
-
* @param
|
|
615
|
+
* @param position beforebegin, afterbegin, beforeend or afterend
|
|
616
|
+
* @param text The text to insert
|
|
644
617
|
*/
|
|
645
618
|
insertAdjacentText(position: string, text: string): void;
|
|
646
619
|
/**
|
|
647
620
|
* Returns a boolean value indicating whether or not the element would be selected by the specified selector string.
|
|
648
|
-
* @param
|
|
649
|
-
* @returns {boolean}
|
|
621
|
+
* @param selectors A CSS selector
|
|
650
622
|
*/
|
|
651
623
|
matches(selectors: string): boolean;
|
|
652
624
|
/**
|
|
@@ -655,20 +627,17 @@ export interface PseudoElement extends PseudoNode {
|
|
|
655
627
|
prepend(...nodes: Array<PseudoNode | string>): void;
|
|
656
628
|
/**
|
|
657
629
|
* Returns the first Node which matches the specified selector string relative to the element.
|
|
658
|
-
* @param
|
|
659
|
-
* @returns {PseudoElement|null}
|
|
630
|
+
* @param selectors A CSS selector
|
|
660
631
|
*/
|
|
661
632
|
querySelector(selectors: string): PseudoElement | null;
|
|
662
633
|
/**
|
|
663
634
|
* Returns a NodeList of nodes which match the specified selector string relative to the element.
|
|
664
|
-
* @param
|
|
665
|
-
* @returns {Array<PseudoElement>}
|
|
635
|
+
* @param selectors A CSS selector
|
|
666
636
|
*/
|
|
667
637
|
querySelectorAll(selectors: string): Array<PseudoElement>;
|
|
668
638
|
/**
|
|
669
639
|
* Releases (stops) pointer capture that was previously set for a specific pointer event.
|
|
670
|
-
* @param
|
|
671
|
-
* @returns {undefined}
|
|
640
|
+
* @param pointerId
|
|
672
641
|
*/
|
|
673
642
|
releasePointerCapture(pointerId: number): void;
|
|
674
643
|
/**
|
|
@@ -687,8 +656,8 @@ export interface PseudoElement extends PseudoNode {
|
|
|
687
656
|
/**
|
|
688
657
|
* Removes the attribute with the specified name and namespace, from the current node. There is no real
|
|
689
658
|
* namespace parsing here, so this ignores the namespace and behaves exactly like removeAttribute.
|
|
690
|
-
* @param
|
|
691
|
-
* @param
|
|
659
|
+
* @param namespace Ignored
|
|
660
|
+
* @param attributeName
|
|
692
661
|
*/
|
|
693
662
|
removeAttributeNS(namespace: string, attributeName: string): void;
|
|
694
663
|
/**
|
|
@@ -703,21 +672,18 @@ export interface PseudoElement extends PseudoNode {
|
|
|
703
672
|
/**
|
|
704
673
|
* Asynchronously asks the browser to make the element fullscreen. There is no real fullscreen here, so this just
|
|
705
674
|
* resolves, like a browser granting the request would.
|
|
706
|
-
* @returns {Promise<void>}
|
|
707
675
|
*/
|
|
708
676
|
requestFullscreen(): Promise<void>;
|
|
709
677
|
/**
|
|
710
678
|
* Allows to asynchronously ask for the pointer to be locked on the given element. There is no real pointer lock
|
|
711
679
|
* here, so this just resolves, like a browser granting the request would.
|
|
712
|
-
* @returns {Promise<void>}
|
|
713
680
|
*/
|
|
714
681
|
requestPointerLock(): Promise<void>;
|
|
715
682
|
/**
|
|
716
683
|
* Scrolls to a particular set of coordinates inside a given element. There is no real scrollable viewport here:
|
|
717
684
|
* this just sets scrollLeft / scrollTop.
|
|
718
|
-
* @param
|
|
719
|
-
* @param
|
|
720
|
-
* @returns {undefined}
|
|
685
|
+
* @param x
|
|
686
|
+
* @param y
|
|
721
687
|
*/
|
|
722
688
|
scroll(x: number | {
|
|
723
689
|
left?: number;
|
|
@@ -725,9 +691,8 @@ export interface PseudoElement extends PseudoNode {
|
|
|
725
691
|
}, y: number): void;
|
|
726
692
|
/**
|
|
727
693
|
* Scrolls an element by the given amount, relative to the current position.
|
|
728
|
-
* @param
|
|
729
|
-
* @param
|
|
730
|
-
* @returns {undefined}
|
|
694
|
+
* @param x
|
|
695
|
+
* @param y
|
|
731
696
|
*/
|
|
732
697
|
scrollBy(x: number | {
|
|
733
698
|
left?: number;
|
|
@@ -736,14 +701,12 @@ export interface PseudoElement extends PseudoNode {
|
|
|
736
701
|
/**
|
|
737
702
|
* Scrolls an ancestor until the element gets into view. There is no real viewport here for that to mean anything,
|
|
738
703
|
* so this does nothing.
|
|
739
|
-
* @returns {undefined}
|
|
740
704
|
*/
|
|
741
705
|
scrollIntoView(): void;
|
|
742
706
|
/**
|
|
743
707
|
* Scrolls to a particular set of coordinates inside a given element. An alias for scroll.
|
|
744
|
-
* @param
|
|
745
|
-
* @param
|
|
746
|
-
* @returns {undefined}
|
|
708
|
+
* @param x
|
|
709
|
+
* @param y
|
|
747
710
|
*/
|
|
748
711
|
scrollTo(x: number | {
|
|
749
712
|
left?: number;
|
|
@@ -767,23 +730,21 @@ export interface PseudoElement extends PseudoNode {
|
|
|
767
730
|
/**
|
|
768
731
|
* Sets the value of the attribute with the specified name and namespace, from the current node. There is no
|
|
769
732
|
* real namespace parsing here, so this ignores the namespace and behaves exactly like setAttribute.
|
|
770
|
-
* @param
|
|
771
|
-
* @param
|
|
772
|
-
* @param
|
|
733
|
+
* @param namespace Ignored
|
|
734
|
+
* @param attributeName
|
|
735
|
+
* @param attributeValue
|
|
773
736
|
*/
|
|
774
737
|
setAttributeNS(namespace: string, attributeName: string, attributeValue: string): void;
|
|
775
738
|
/**
|
|
776
739
|
* Designates a specific element as the capture target of future pointer events.
|
|
777
|
-
* @param
|
|
778
|
-
* @returns {undefined}
|
|
740
|
+
* @param pointerId
|
|
779
741
|
*/
|
|
780
742
|
setPointerCapture(pointerId: number): void;
|
|
781
743
|
/**
|
|
782
744
|
* Toggles a boolean attribute, removing it if it is present and adding it if it is not present, on the specified
|
|
783
745
|
* element - unless force says which of those to do instead. Returns whether the attribute is present afterwards.
|
|
784
|
-
* @param
|
|
785
|
-
* @param
|
|
786
|
-
* @returns {boolean}
|
|
746
|
+
* @param attributeName
|
|
747
|
+
* @param force
|
|
787
748
|
*/
|
|
788
749
|
toggleAttribute(attributeName: string, force: boolean): boolean;
|
|
789
750
|
}
|
|
@@ -1,79 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM Event Class.
|
|
5
3
|
*/
|
|
6
4
|
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
7
5
|
/**
|
|
8
6
|
* 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
7
|
*/
|
|
33
8
|
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
|
-
*/
|
|
9
|
+
/** A Boolean indicating whether the event bubbles up through the Dom or not. */
|
|
43
10
|
get bubbles(): boolean;
|
|
11
|
+
/** A Boolean indicating whether the event is cancelable. */
|
|
44
12
|
get cancelable(): boolean;
|
|
13
|
+
/** A Boolean value indicating whether the event can bubble across the boundary between the shadow Dom and the regular Dom. */
|
|
45
14
|
get composed(): boolean;
|
|
15
|
+
/** A reference to the currently registered target for the event. This is the object to which the event is currently slated to be sent; it's possible this has been changed along the way through re-targeting. */
|
|
46
16
|
get currentTarget(): PseudoEventTarget;
|
|
17
|
+
/** Indicates whether event.preventDefault() has been called on the event. */
|
|
47
18
|
get defaultPrevented(): boolean;
|
|
19
|
+
/** Indicates which phase of the event flow is being processed. Uses PseudoEvent constants. */
|
|
48
20
|
get eventPhase(): number;
|
|
21
|
+
/** Indicates whether the event was initiated by the browser (after a user click for instance) or by a script (using an event creation method, like event.initEvent) */
|
|
49
22
|
get isTrusted(): boolean;
|
|
23
|
+
/** A reference to the target to which the event was originally dispatched. */
|
|
50
24
|
get target(): PseudoEventTarget;
|
|
25
|
+
/** The time at which the event was created (in milliseconds). By specification, this value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this to be a DomHighResTimeStamp instead. */
|
|
51
26
|
get timeStamp(): number;
|
|
27
|
+
/** The name of the event (case-insensitive). */
|
|
52
28
|
get type(): string;
|
|
53
29
|
/**
|
|
54
30
|
* 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
31
|
*/
|
|
58
32
|
composedPath(): Array<PseudoEventTarget>;
|
|
59
33
|
/**
|
|
60
34
|
* Cancels the event (if it is cancelable).
|
|
61
|
-
* @method
|
|
62
|
-
* @returns {null}
|
|
63
35
|
*/
|
|
64
36
|
preventDefault(): null;
|
|
65
37
|
/**
|
|
66
38
|
* For this particular event, no other listener will be called.
|
|
67
39
|
* Neither those attached on the same element, nor those attached on elements which will be traversed later (in
|
|
68
40
|
* capture phase, for instance)
|
|
69
|
-
* @method
|
|
70
|
-
* @returns {null}
|
|
71
41
|
*/
|
|
72
42
|
stopImmediatePropagation(): null;
|
|
73
43
|
/**
|
|
74
44
|
* Stops the propagation of events further along in the Dom.
|
|
75
|
-
* @method
|
|
76
|
-
* @returns {null}
|
|
77
45
|
*/
|
|
78
46
|
stopPropagation(): null;
|
|
79
47
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM EventTarget Class.
|
|
5
3
|
*/
|
|
6
4
|
import { PseudoEvent } from './PseudoEvent';
|
|
7
5
|
export type listenerOptions = {
|
|
@@ -11,11 +9,6 @@ export type listenerOptions = {
|
|
|
11
9
|
};
|
|
12
10
|
/**
|
|
13
11
|
* 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
12
|
*/
|
|
20
13
|
export interface PseudoEventTarget {
|
|
21
14
|
/**
|
|
@@ -23,24 +16,22 @@ export interface PseudoEventTarget {
|
|
|
23
16
|
*/
|
|
24
17
|
/**
|
|
25
18
|
* Registers an event handler of a specific event type on the EventTarget.
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
19
|
+
* @param type
|
|
20
|
+
* @param callback
|
|
21
|
+
* @param useCapture
|
|
29
22
|
*/
|
|
30
23
|
addEventListener(type: string, callback: Function | {
|
|
31
24
|
handleEvent: Function;
|
|
32
25
|
} | any, useCapture: listenerOptions | boolean): void;
|
|
33
26
|
/**
|
|
34
27
|
* Removes an event listener from the EventTarget.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
28
|
+
* @param type
|
|
29
|
+
* @param callback
|
|
37
30
|
*/
|
|
38
31
|
removeEventListener(type: string, callback: Function, options?: listenerOptions | boolean): void;
|
|
39
32
|
/**
|
|
40
33
|
* Dispatches an event to this EventTarget.
|
|
41
|
-
* @param
|
|
42
|
-
* @param {EventTarget|PseudoEventTarget} target
|
|
43
|
-
* @returns {boolean}
|
|
34
|
+
* @param event
|
|
44
35
|
*/
|
|
45
36
|
dispatchEvent(event: PseudoEvent): boolean;
|
|
46
37
|
}
|
|
@@ -10,14 +10,12 @@ export interface PseudoHTMLCollection extends Iterable<PseudoElement> {
|
|
|
10
10
|
get length(): number;
|
|
11
11
|
/**
|
|
12
12
|
* The element at the given index, or null when there is none.
|
|
13
|
-
* @param
|
|
14
|
-
* @returns {PseudoElement|null}
|
|
13
|
+
* @param index
|
|
15
14
|
*/
|
|
16
15
|
item(index: number): PseudoElement | null;
|
|
17
16
|
/**
|
|
18
17
|
* The element whose id, or whose name attribute, is the given value, or null when there is none.
|
|
19
|
-
* @param
|
|
20
|
-
* @returns {PseudoElement|null}
|
|
18
|
+
* @param name
|
|
21
19
|
*/
|
|
22
20
|
namedItem(name: string): PseudoElement | null;
|
|
23
21
|
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM HTMLElement Class.
|
|
5
3
|
*/
|
|
6
4
|
import { PseudoElement } from './PseudoElement';
|
|
7
5
|
import { PseudoCSSStyleDeclaration } from './PseudoCSSStyleDeclaration';
|
|
8
6
|
/**
|
|
9
7
|
* Simulate the behaviour of the HTMLElement Class when there is no DOM available.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @property {number} offsetTop - The position of the top side of the element based on the parent element
|
|
18
|
-
* @property {number} offsetWidth - The width of the element as offset by the parent element
|
|
19
|
-
* @property {string} title - The title attribute which affects the text visible on hover
|
|
8
|
+
*
|
|
9
|
+
* It also has these simple properties, which are stored as attributes:
|
|
10
|
+
* - `hidden`: state of whether the element is visible
|
|
11
|
+
* - `title`: the title attribute, which affects the text visible on hover
|
|
12
|
+
* - `offsetHeight`, `offsetWidth`: the height and width of the element as offset by the parent element
|
|
13
|
+
* - `offsetLeft`, `offsetTop`: the position of the left and top sides of the element based on the parent element
|
|
14
|
+
* - `offsetParent`: a reference to the closest positioned parent element
|
|
20
15
|
*/
|
|
21
16
|
export interface PseudoHTMLElement extends PseudoElement {
|
|
22
17
|
/**
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* Substitute for the DOM Node Class.
|
|
5
3
|
*/
|
|
6
4
|
import { PseudoEventTarget } from './PseudoEventTarget';
|
|
7
5
|
import { PseudoNodeList } from '../classes/PseudoNodeList';
|
|
@@ -11,12 +9,6 @@ import { PseudoElement } from './PseudoElement';
|
|
|
11
9
|
import { PseudoDocumentFragment } from './PseudoDocumentFragment';
|
|
12
10
|
/**
|
|
13
11
|
* 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
12
|
*/
|
|
21
13
|
export interface PseudoNode extends PseudoEventTarget {
|
|
22
14
|
/**
|
|
@@ -99,8 +91,7 @@ export interface PseudoNode extends PseudoEventTarget {
|
|
|
99
91
|
set textContent(text: string | null);
|
|
100
92
|
/**
|
|
101
93
|
* 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
|
|
103
|
-
* @returns {PseudoNode}
|
|
94
|
+
* @param childNode
|
|
104
95
|
*/
|
|
105
96
|
appendChild(childNode: PseudoNode): PseudoNode;
|
|
106
97
|
/**
|
|
@@ -166,8 +157,7 @@ export interface PseudoNode extends PseudoEventTarget {
|
|
|
166
157
|
normalize(): void;
|
|
167
158
|
/**
|
|
168
159
|
* Removes a child node from the current element, which must be a child of the current node.
|
|
169
|
-
* @param
|
|
170
|
-
* @returns {PseudoNode}
|
|
160
|
+
* @param child
|
|
171
161
|
*/
|
|
172
162
|
removeChild(child: PseudoNode): PseudoNode;
|
|
173
163
|
/**
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
2
|
+
* All of the Pseudo Dom Helper Objects functions for simulating parts of the DOM when running scripts in NodeJs.
|
|
5
3
|
*/
|
|
6
4
|
import { EventService as PseudoEvent } from './services/EventService';
|
|
7
5
|
import PseudoEventTarget from './services/EventTargetService';
|
|
@@ -26,9 +24,6 @@ import simulate from './simulate';
|
|
|
26
24
|
import { TextService as PseudoText, CommentService as PseudoComment } from './services/NodeService';
|
|
27
25
|
/**
|
|
28
26
|
* All methods exported from this module are encapsulated within pseudoDom.
|
|
29
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
30
|
-
* @typedef {Object} pseudoDom
|
|
31
|
-
* @module pseudoDom/objects
|
|
32
27
|
*/
|
|
33
28
|
declare const pseudoDom: {
|
|
34
29
|
generateDocument: (root: Window | any, context?: object) => Window | PseudoEventTarget;
|
package/dist/main.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
6
|
-
* @version 1.0.0
|
|
4
|
+
* All of the Pseudo Dom Helper Objects functions for simulating parts of the DOM when running scripts in NodeJs.
|
|
7
5
|
*/
|
|
8
6
|
const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
9
7
|
return mod && mod.__esModule
|
|
@@ -131,9 +129,6 @@ Object.defineProperty(exports, 'PseudoComment', {
|
|
|
131
129
|
})
|
|
132
130
|
/**
|
|
133
131
|
* All methods exported from this module are encapsulated within pseudoDom.
|
|
134
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
135
|
-
* @typedef {Object} pseudoDom
|
|
136
|
-
* @module pseudoDom/objects
|
|
137
132
|
*/
|
|
138
133
|
const pseudoDom = {
|
|
139
134
|
generateDocument: generateDocument_1.default,
|