pseudo-dom 0.3.0 → 0.5.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.
Files changed (70) hide show
  1. package/README.md +1632 -111
  2. package/browser/pseudo-dom.js +23759 -1844
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoHTMLDocument.d.ts +33 -1
  5. package/dist/classes/PseudoHTMLDocument.js +80 -2
  6. package/dist/classes/PseudoHTMLDocument.min.js +1 -1
  7. package/dist/factories/createEvent.d.ts +28 -0
  8. package/dist/factories/createEvent.js +56 -0
  9. package/dist/factories/createEvent.min.js +1 -0
  10. package/dist/factories/eventDefaults.d.ts +31 -0
  11. package/dist/factories/eventDefaults.js +105 -0
  12. package/dist/factories/eventDefaults.min.js +1 -0
  13. package/dist/factories.d.ts +6 -0
  14. package/dist/factories.js +5 -1
  15. package/dist/factories.min.js +1 -1
  16. package/dist/functions/activeElement.d.ts +14 -0
  17. package/dist/functions/activeElement.js +33 -0
  18. package/dist/functions/activeElement.min.js +1 -0
  19. package/dist/functions/modifierState.d.ts +29 -0
  20. package/dist/functions/modifierState.js +41 -0
  21. package/dist/functions/modifierState.min.js +1 -0
  22. package/dist/main.d.ts +35 -1
  23. package/dist/main.js +81 -1
  24. package/dist/main.min.js +1 -1
  25. package/dist/services/AttrService.d.ts +6 -0
  26. package/dist/services/AttrService.js +24 -0
  27. package/dist/services/AttrService.min.js +1 -1
  28. package/dist/services/CommentService.d.ts +1 -0
  29. package/dist/services/CommentService.js +13 -0
  30. package/dist/services/CommentService.min.js +1 -0
  31. package/dist/services/CustomEventService.d.ts +37 -0
  32. package/dist/services/CustomEventService.js +35 -0
  33. package/dist/services/CustomEventService.min.js +1 -0
  34. package/dist/services/ElementService.d.ts +20 -0
  35. package/dist/services/ElementService.js +82 -15
  36. package/dist/services/ElementService.min.js +1 -1
  37. package/dist/services/EventService.d.ts +2 -0
  38. package/dist/services/EventService.js +7 -1
  39. package/dist/services/EventService.min.js +1 -1
  40. package/dist/services/FocusEventService.d.ts +32 -0
  41. package/dist/services/FocusEventService.js +35 -0
  42. package/dist/services/FocusEventService.min.js +1 -0
  43. package/dist/services/HTMLElementService.d.ts +20 -0
  44. package/dist/services/HTMLElementService.js +95 -0
  45. package/dist/services/HTMLElementService.min.js +1 -1
  46. package/dist/services/InputEventService.d.ts +41 -0
  47. package/dist/services/InputEventService.js +47 -0
  48. package/dist/services/InputEventService.min.js +1 -0
  49. package/dist/services/KeyboardEventService.d.ts +70 -0
  50. package/dist/services/KeyboardEventService.js +86 -0
  51. package/dist/services/KeyboardEventService.min.js +1 -0
  52. package/dist/services/MouseEventService.d.ts +80 -0
  53. package/dist/services/MouseEventService.js +108 -0
  54. package/dist/services/MouseEventService.min.js +1 -0
  55. package/dist/services/NodeService.d.ts +105 -8
  56. package/dist/services/NodeService.js +313 -17
  57. package/dist/services/NodeService.min.js +1 -1
  58. package/dist/services/PointerEventService.d.ts +51 -0
  59. package/dist/services/PointerEventService.js +67 -0
  60. package/dist/services/PointerEventService.min.js +1 -0
  61. package/dist/services/TextService.d.ts +1 -0
  62. package/dist/services/TextService.js +13 -0
  63. package/dist/services/TextService.min.js +1 -0
  64. package/dist/services/UIEventService.d.ts +43 -0
  65. package/dist/services/UIEventService.js +42 -0
  66. package/dist/services/UIEventService.min.js +1 -0
  67. package/dist/simulate.d.ts +32 -0
  68. package/dist/simulate.js +115 -0
  69. package/dist/simulate.min.js +1 -0
  70. package/package.json +3 -2
package/dist/main.js CHANGED
@@ -15,7 +15,7 @@ const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
15
15
  Object.defineProperty(exports, '__esModule', {
16
16
  value: true
17
17
  })
18
- exports.PseudoHTMLDocument = exports.PseudoHTMLElement = exports.PseudoElement = exports.PseudoNode = exports.PseudoEventTarget = exports.PseudoEvent = exports.generateDocument = void 0
18
+ exports.PseudoHTMLDocument = exports.PseudoHTMLElement = exports.PseudoElement = exports.PseudoComment = exports.PseudoText = exports.PseudoNode = exports.PseudoEventTarget = exports.PseudoCustomEvent = exports.PseudoInputEvent = exports.PseudoFocusEvent = exports.PseudoKeyboardEvent = exports.PseudoPointerEvent = exports.PseudoMouseEvent = exports.PseudoUIEvent = exports.PseudoEvent = exports.simulate = exports.eventDefaults = exports.createEvent = exports.generateDocument = void 0
19
19
  const EventService_1 = require('./services/EventService')
20
20
  Object.defineProperty(exports, 'PseudoEvent', {
21
21
  enumerable: true,
@@ -50,6 +50,74 @@ const PseudoHTMLDocument_1 = __importDefault(require('./classes/PseudoHTMLDocume
50
50
  exports.PseudoHTMLDocument = PseudoHTMLDocument_1.default
51
51
  const generateDocument_1 = __importDefault(require('./factories/generateDocument'))
52
52
  exports.generateDocument = generateDocument_1.default
53
+ const createEvent_1 = __importDefault(require('./factories/createEvent'))
54
+ exports.createEvent = createEvent_1.default
55
+ const eventDefaults_1 = __importDefault(require('./factories/eventDefaults'))
56
+ exports.eventDefaults = eventDefaults_1.default
57
+ const UIEventService_1 = require('./services/UIEventService')
58
+ Object.defineProperty(exports, 'PseudoUIEvent', {
59
+ enumerable: true,
60
+ get: function () {
61
+ return UIEventService_1.UIEventService
62
+ }
63
+ })
64
+ const MouseEventService_1 = require('./services/MouseEventService')
65
+ Object.defineProperty(exports, 'PseudoMouseEvent', {
66
+ enumerable: true,
67
+ get: function () {
68
+ return MouseEventService_1.MouseEventService
69
+ }
70
+ })
71
+ const PointerEventService_1 = require('./services/PointerEventService')
72
+ Object.defineProperty(exports, 'PseudoPointerEvent', {
73
+ enumerable: true,
74
+ get: function () {
75
+ return PointerEventService_1.PointerEventService
76
+ }
77
+ })
78
+ const KeyboardEventService_1 = require('./services/KeyboardEventService')
79
+ Object.defineProperty(exports, 'PseudoKeyboardEvent', {
80
+ enumerable: true,
81
+ get: function () {
82
+ return KeyboardEventService_1.KeyboardEventService
83
+ }
84
+ })
85
+ const FocusEventService_1 = require('./services/FocusEventService')
86
+ Object.defineProperty(exports, 'PseudoFocusEvent', {
87
+ enumerable: true,
88
+ get: function () {
89
+ return FocusEventService_1.FocusEventService
90
+ }
91
+ })
92
+ const InputEventService_1 = require('./services/InputEventService')
93
+ Object.defineProperty(exports, 'PseudoInputEvent', {
94
+ enumerable: true,
95
+ get: function () {
96
+ return InputEventService_1.InputEventService
97
+ }
98
+ })
99
+ const CustomEventService_1 = require('./services/CustomEventService')
100
+ Object.defineProperty(exports, 'PseudoCustomEvent', {
101
+ enumerable: true,
102
+ get: function () {
103
+ return CustomEventService_1.CustomEventService
104
+ }
105
+ })
106
+ const simulate_1 = __importDefault(require('./simulate'))
107
+ exports.simulate = simulate_1.default
108
+ const NodeService_2 = require('./services/NodeService')
109
+ Object.defineProperty(exports, 'PseudoText', {
110
+ enumerable: true,
111
+ get: function () {
112
+ return NodeService_2.TextService
113
+ }
114
+ })
115
+ Object.defineProperty(exports, 'PseudoComment', {
116
+ enumerable: true,
117
+ get: function () {
118
+ return NodeService_2.CommentService
119
+ }
120
+ })
53
121
  /**
54
122
  * All methods exported from this module are encapsulated within pseudoDom.
55
123
  * @author Joshua Heagle <joshuaheagle@gmail.com>
@@ -58,9 +126,21 @@ exports.generateDocument = generateDocument_1.default
58
126
  */
59
127
  const pseudoDom = {
60
128
  generateDocument: generateDocument_1.default,
129
+ createEvent: createEvent_1.default,
130
+ eventDefaults: eventDefaults_1.default,
131
+ simulate: simulate_1.default,
61
132
  PseudoEvent: EventService_1.EventService,
133
+ PseudoUIEvent: UIEventService_1.UIEventService,
134
+ PseudoMouseEvent: MouseEventService_1.MouseEventService,
135
+ PseudoPointerEvent: PointerEventService_1.PointerEventService,
136
+ PseudoKeyboardEvent: KeyboardEventService_1.KeyboardEventService,
137
+ PseudoFocusEvent: FocusEventService_1.FocusEventService,
138
+ PseudoInputEvent: InputEventService_1.InputEventService,
139
+ PseudoCustomEvent: CustomEventService_1.CustomEventService,
62
140
  PseudoEventTarget: EventTargetService_1.default,
63
141
  PseudoNode: NodeService_1.NodeService,
142
+ PseudoText: NodeService_2.TextService,
143
+ PseudoComment: NodeService_2.CommentService,
64
144
  PseudoElement: ElementService_1.ElementService,
65
145
  PseudoHTMLElement: HTMLElementService_1.HTMLElementService,
66
146
  PseudoHTMLDocument: PseudoHTMLDocument_1.default
package/dist/main.min.js CHANGED
@@ -1 +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);
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.PseudoComment=exports.PseudoText=exports.PseudoNode=exports.PseudoEventTarget=exports.PseudoCustomEvent=exports.PseudoInputEvent=exports.PseudoFocusEvent=exports.PseudoKeyboardEvent=exports.PseudoPointerEvent=exports.PseudoMouseEvent=exports.PseudoUIEvent=exports.PseudoEvent=exports.simulate=exports.eventDefaults=exports.createEvent=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 createEvent_1=__importDefault(require("./factories/createEvent"));exports.createEvent=createEvent_1.default;const eventDefaults_1=__importDefault(require("./factories/eventDefaults"));exports.eventDefaults=eventDefaults_1.default;const UIEventService_1=require("./services/UIEventService");Object.defineProperty(exports,"PseudoUIEvent",{enumerable:!0,get:function(){return UIEventService_1.UIEventService}});const MouseEventService_1=require("./services/MouseEventService");Object.defineProperty(exports,"PseudoMouseEvent",{enumerable:!0,get:function(){return MouseEventService_1.MouseEventService}});const PointerEventService_1=require("./services/PointerEventService");Object.defineProperty(exports,"PseudoPointerEvent",{enumerable:!0,get:function(){return PointerEventService_1.PointerEventService}});const KeyboardEventService_1=require("./services/KeyboardEventService");Object.defineProperty(exports,"PseudoKeyboardEvent",{enumerable:!0,get:function(){return KeyboardEventService_1.KeyboardEventService}});const FocusEventService_1=require("./services/FocusEventService");Object.defineProperty(exports,"PseudoFocusEvent",{enumerable:!0,get:function(){return FocusEventService_1.FocusEventService}});const InputEventService_1=require("./services/InputEventService");Object.defineProperty(exports,"PseudoInputEvent",{enumerable:!0,get:function(){return InputEventService_1.InputEventService}});const CustomEventService_1=require("./services/CustomEventService");Object.defineProperty(exports,"PseudoCustomEvent",{enumerable:!0,get:function(){return CustomEventService_1.CustomEventService}});const simulate_1=__importDefault(require("./simulate"));exports.simulate=simulate_1.default;const NodeService_2=require("./services/NodeService");Object.defineProperty(exports,"PseudoText",{enumerable:!0,get:function(){return NodeService_2.TextService}}),Object.defineProperty(exports,"PseudoComment",{enumerable:!0,get:function(){return NodeService_2.CommentService}});const pseudoDom={generateDocument:generateDocument_1.default,createEvent:createEvent_1.default,eventDefaults:eventDefaults_1.default,simulate:simulate_1.default,PseudoEvent:EventService_1.EventService,PseudoUIEvent:UIEventService_1.UIEventService,PseudoMouseEvent:MouseEventService_1.MouseEventService,PseudoPointerEvent:PointerEventService_1.PointerEventService,PseudoKeyboardEvent:KeyboardEventService_1.KeyboardEventService,PseudoFocusEvent:FocusEventService_1.FocusEventService,PseudoInputEvent:InputEventService_1.InputEventService,PseudoCustomEvent:CustomEventService_1.CustomEventService,PseudoEventTarget:EventTargetService_1.default,PseudoNode:NodeService_1.NodeService,PseudoText:NodeService_2.TextService,PseudoComment:NodeService_2.CommentService,PseudoElement:ElementService_1.ElementService,PseudoHTMLElement:HTMLElementService_1.HTMLElementService,PseudoHTMLDocument:PseudoHTMLDocument_1.default};exports.default=pseudoDom,"undefined"!=typeof window&&(window.pseudoDom=pseudoDom);
@@ -22,6 +22,12 @@ export declare class AttrService extends NodeService implements PseudoAttr {
22
22
  * @constructor
23
23
  */
24
24
  constructor(name?: string, value?: string, ownerElement?: PseudoElement | null, namespaceURI?: string, prefix?: string | null);
25
+ protected get acceptsChildren(): boolean;
26
+ get nodeValue(): string | null;
27
+ set nodeValue(value: string | null);
28
+ get textContent(): string | null;
29
+ set textContent(text: string | null);
30
+ protected cloneShallow(): NodeService;
25
31
  get nodeType(): number;
26
32
  get localName(): string;
27
33
  get name(): string;
@@ -30,6 +30,30 @@ class AttrService extends NodeService_1.NodeService {
30
30
  this.nodeNameValue = name
31
31
  }
32
32
 
33
+ get acceptsChildren () {
34
+ return false
35
+ }
36
+
37
+ get nodeValue () {
38
+ return this.value
39
+ }
40
+
41
+ set nodeValue (value) {
42
+ this.value = value === null ? '' : String(value)
43
+ }
44
+
45
+ get textContent () {
46
+ return this.value
47
+ }
48
+
49
+ set textContent (text) {
50
+ this.value = text === null ? '' : String(text)
51
+ }
52
+
53
+ cloneShallow () {
54
+ return new AttrService(this.localName, this.value, null, this.namespaceURI, this.prefix)
55
+ }
56
+
33
57
  get nodeType () {
34
58
  return NodeService_1.NodeService.ATTRIBUTE_NODE
35
59
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AttrService=void 0;const NodeService_1=require("./NodeService");class AttrService extends NodeService_1.NodeService{constructor(e="",t="",r=null,i="",s=null){super(),this.attributeName=e,this.value=t,this.element=r,this.namespace=i,this.namespacePrefix=s,this.nodeNameValue=e}get nodeType(){return NodeService_1.NodeService.ATTRIBUTE_NODE}get localName(){return this.attributeName}get name(){return this.namespacePrefix?`${this.namespacePrefix}:${this.attributeName}`:this.attributeName}get namespaceURI(){return this.namespace}get ownerElement(){return this.element}get prefix(){return this.namespacePrefix}}exports.AttrService=AttrService;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AttrService=void 0;const NodeService_1=require("./NodeService");class AttrService extends NodeService_1.NodeService{constructor(e="",t="",r=null,i="",n=null){super(),this.attributeName=e,this.value=t,this.element=r,this.namespace=i,this.namespacePrefix=n,this.nodeNameValue=e}get acceptsChildren(){return!1}get nodeValue(){return this.value}set nodeValue(e){this.value=null===e?"":String(e)}get textContent(){return this.value}set textContent(e){this.value=null===e?"":String(e)}cloneShallow(){return new AttrService(this.localName,this.value,null,this.namespaceURI,this.prefix)}get nodeType(){return NodeService_1.NodeService.ATTRIBUTE_NODE}get localName(){return this.attributeName}get name(){return this.namespacePrefix?`${this.namespacePrefix}:${this.attributeName}`:this.attributeName}get namespaceURI(){return this.namespace}get ownerElement(){return this.element}get prefix(){return this.namespacePrefix}}exports.AttrService=AttrService;
@@ -0,0 +1 @@
1
+ export { CommentService } from './NodeService';
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.CommentService = void 0
7
+ const NodeService_1 = require('./NodeService')
8
+ Object.defineProperty(exports, 'CommentService', {
9
+ enumerable: true,
10
+ get: function () {
11
+ return NodeService_1.CommentService
12
+ }
13
+ })
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommentService=void 0;var NodeService_1=require("./NodeService");Object.defineProperty(exports,"CommentService",{enumerable:!0,get:function(){return NodeService_1.CommentService}});
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Substitute for the DOM CustomEvent Class.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { EventService } from './EventService';
7
+ /**
8
+ * The options for creating a custom event.
9
+ * @typedef {Object} CustomEventInit
10
+ * @property {boolean} [bubbles=false]
11
+ * @property {boolean} [cancelable=false]
12
+ * @property {boolean} [composed=false]
13
+ * @property {*} [detail=null] Whatever data the event should carry
14
+ */
15
+ export type CustomEventInit = {
16
+ bubbles?: boolean;
17
+ cancelable?: boolean;
18
+ composed?: boolean;
19
+ detail?: any;
20
+ };
21
+ /**
22
+ * Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
23
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
24
+ * @class
25
+ * @augments EventService
26
+ * @property {*} detail
27
+ */
28
+ export declare class CustomEventService extends EventService {
29
+ private readonly eventDetail;
30
+ /**
31
+ * @param {string} [typeArg=''] The type of the event
32
+ * @param {CustomEventInit} [init={}] The options for the event
33
+ * @constructor
34
+ */
35
+ constructor(typeArg?: string, init?: CustomEventInit);
36
+ get detail(): any;
37
+ }
@@ -0,0 +1,35 @@
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.CustomEventService = void 0
7
+ /**
8
+ * @file Substitute for the DOM CustomEvent Class.
9
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
10
+ * @version 1.0.0
11
+ */
12
+ const EventService_1 = require('./EventService')
13
+ /**
14
+ * Simulate the behaviour of the CustomEvent Class when there is no DOM available: an event which carries data.
15
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
16
+ * @class
17
+ * @augments EventService
18
+ * @property {*} detail
19
+ */
20
+ class CustomEventService extends EventService_1.EventService {
21
+ /**
22
+ * @param {string} [typeArg=''] The type of the event
23
+ * @param {CustomEventInit} [init={}] The options for the event
24
+ * @constructor
25
+ */
26
+ constructor (typeArg = '', init = {}) {
27
+ super(typeArg, init)
28
+ this.eventDetail = typeof init.detail === 'undefined' ? null : init.detail
29
+ }
30
+
31
+ get detail () {
32
+ return this.eventDetail
33
+ }
34
+ }
35
+ exports.CustomEventService = CustomEventService
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomEventService=void 0;const EventService_1=require("./EventService");class CustomEventService extends EventService_1.EventService{constructor(e="",t={}){super(e,t),this.eventDetail=void 0===t.detail?null:t.detail}get detail(){return this.eventDetail}}exports.CustomEventService=CustomEventService;
@@ -50,6 +50,26 @@ export declare class ElementService extends NodeService implements Partial<Pseud
50
50
  parent?: PseudoNode | null;
51
51
  children?: Array<any>;
52
52
  });
53
+ /**
54
+ * The attributes with the values they have now: the ones which are also properties (className, id, style, ...) can
55
+ * have been changed through the property, which does not change the stored list.
56
+ * @returns {Array<{name: string, value: *}>}
57
+ */
58
+ private currentAttributes;
59
+ get nodeName(): string;
60
+ /**
61
+ * A copy of this element without its children: the same tag and attributes (the values which are objects, such as
62
+ * style, are copied too rather than shared), but not its parent or listeners.
63
+ * @returns {ElementService}
64
+ */
65
+ protected cloneShallow(): NodeService;
66
+ /**
67
+ * Elements are equal when they have the same tag and the same attributes (in any order), which is what isEqualNode
68
+ * checks before it compares the children.
69
+ * @param {NodeService} other The element to compare with
70
+ * @returns {boolean}
71
+ */
72
+ protected equalsShallow(other: NodeService): boolean;
53
73
  get tagName(): string;
54
74
  get nodeType(): number;
55
75
  get attributes(): PseudoNamedNodeMap;
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  require('core-js/modules/esnext.iterator.constructor.js')
4
+ require('core-js/modules/esnext.iterator.every.js')
4
5
  require('core-js/modules/esnext.iterator.find.js')
5
6
  require('core-js/modules/esnext.iterator.for-each.js')
6
7
  require('core-js/modules/esnext.iterator.map.js')
@@ -16,12 +17,14 @@ Object.defineProperty(exports, '__esModule', {
16
17
  value: true
17
18
  })
18
19
  exports.ElementService = void 0
19
- const EventService_1 = require('./EventService')
20
+ const createEvent_1 = __importDefault(require('../factories/createEvent'))
20
21
  const NodeService_1 = require('./NodeService')
21
22
  const AttrService_1 = require('./AttrService')
22
23
  const DOMTokenListService_1 = require('./DOMTokenListService')
23
24
  const NamedNodeMapService_1 = require('./NamedNodeMapService')
24
25
  const getParentNodesFromAttribute_1 = __importDefault(require('../functions/getParentNodesFromAttribute'))
26
+ const cloneObject_1 = __importDefault(require('si-funciona/dist/helpers/objects/cloneObject'))
27
+ const isEqual_1 = __importDefault(require('si-funciona/dist/helpers/objects/isEqual'))
25
28
  /**
26
29
  * Simulate the behaviour of the Element Class when there is no DOM available.
27
30
  * @author Joshua Heagle <joshuaheagle@gmail.com>
@@ -86,6 +89,70 @@ class ElementService extends NodeService_1.NodeService {
86
89
  }
87
90
  }
88
91
 
92
+ /**
93
+ * The attributes with the values they have now: the ones which are also properties (className, id, style, ...) can
94
+ * have been changed through the property, which does not change the stored list.
95
+ * @returns {Array<{name: string, value: *}>}
96
+ */
97
+ currentAttributes () {
98
+ return this.attributeList.map(({
99
+ name,
100
+ value
101
+ }) => ({
102
+ name,
103
+ value: this.propertyAttributes.indexOf(name) >= 0 ? this[name] : value
104
+ }))
105
+ }
106
+
107
+ get nodeName () {
108
+ return this.tag
109
+ }
110
+
111
+ /**
112
+ * A copy of this element without its children: the same tag and attributes (the values which are objects, such as
113
+ * style, are copied too rather than shared), but not its parent or listeners.
114
+ * @returns {ElementService}
115
+ */
116
+ cloneShallow () {
117
+ const copy = new this.constructor({
118
+ tagName: this.tag
119
+ })
120
+ copy.attributeList.length = 0
121
+ this.currentAttributes().forEach(({
122
+ name,
123
+ value
124
+ }) => {
125
+ const copied = typeof value === 'object' && value !== null ? (0, cloneObject_1.default)(value) : value
126
+ copy.attributeList.push({
127
+ name,
128
+ value: copied
129
+ })
130
+ if (copy.propertyAttributes.indexOf(name) >= 0) {
131
+ copy[name] = copied
132
+ }
133
+ })
134
+ copy.ownerDocumentStore = this.ownerDocumentStore
135
+ return copy
136
+ }
137
+
138
+ /**
139
+ * Elements are equal when they have the same tag and the same attributes (in any order), which is what isEqualNode
140
+ * checks before it compares the children.
141
+ * @param {NodeService} other The element to compare with
142
+ * @returns {boolean}
143
+ */
144
+ equalsShallow (other) {
145
+ const mine = this.currentAttributes()
146
+ const theirs = other.currentAttributes()
147
+ return this.nodeName === other.nodeName && mine.length === theirs.length && mine.every(({
148
+ name,
149
+ value
150
+ }) => {
151
+ const match = theirs.find(attributeOfOther => attributeOfOther.name === name)
152
+ return typeof match !== 'undefined' && (0, isEqual_1.default)(value, match.value)
153
+ })
154
+ }
155
+
89
156
  get tagName () {
90
157
  return this.tag
91
158
  }
@@ -95,7 +162,7 @@ class ElementService extends NodeService_1.NodeService {
95
162
  }
96
163
 
97
164
  get attributes () {
98
- return new NamedNodeMapService_1.NamedNodeMapService(this.attributeList.map(({
165
+ return new NamedNodeMapService_1.NamedNodeMapService(this.currentAttributes().map(({
99
166
  name,
100
167
  value
101
168
  }) => new AttrService_1.AttrService(name, String(value), this)))
@@ -125,20 +192,20 @@ class ElementService extends NodeService_1.NodeService {
125
192
  switch (this.tagName) {
126
193
  case 'button':
127
194
  case 'input':
128
- if (/^(submit|image)$/i.test(this.type || '')) {
129
- // Clicking a submit button submits the form it is in: the form gets a submit event, which can be cancelled
130
- callback = event => {
131
- const forms = (0, getParentNodesFromAttribute_1.default)('tagName', 'form', this)
132
- if (forms.length) {
133
- forms[forms.length - 1].dispatchEvent(new EventService_1.EventService('submit', {
134
- bubbles: true,
135
- cancelable: true
136
- }))
137
- }
195
+ // Clicking a submit button submits the form it is in: the form gets a submit event, which can be cancelled
196
+ callback = event => {
197
+ const type = String(this.getAttribute('type') || this.type || '').toLowerCase()
198
+ const submits = this.tagName === 'button' ? type !== 'button' && type !== 'reset' : /^(submit|image)$/.test(type)
199
+ const forms = (0, getParentNodesFromAttribute_1.default)('tagName', 'form', this)
200
+ if (submits && forms.length && !this.hasAttribute('disabled')) {
201
+ forms[forms.length - 1].dispatchEvent((0, createEvent_1.default)('submit', {}, {
202
+ browser: true,
203
+ trusted: event.isTrusted
204
+ }))
138
205
  }
139
- super.setDefaultEvent('click', callback)
140
- this.defaultEventApplied = true
141
206
  }
207
+ super.setDefaultEvent('click', callback)
208
+ this.defaultEventApplied = true
142
209
  }
143
210
  return callback
144
211
  }
@@ -193,7 +260,7 @@ class ElementService extends NodeService_1.NodeService {
193
260
  * @returns {string|null} The value, or null when there is no such attribute
194
261
  */
195
262
  getAttribute (attributeName) {
196
- const found = this.attributeList.find(({
263
+ const found = this.currentAttributes().find(({
197
264
  name
198
265
  }) => name === attributeName)
199
266
  return found ? found.value : null
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/esnext.iterator.some.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ElementService=void 0;const EventService_1=require("./EventService"),NodeService_1=require("./NodeService"),AttrService_1=require("./AttrService"),DOMTokenListService_1=require("./DOMTokenListService"),NamedNodeMapService_1=require("./NamedNodeMapService"),getParentNodesFromAttribute_1=__importDefault(require("../functions/getParentNodesFromAttribute"));class ElementService extends NodeService_1.NodeService{constructor({tagName:e="",attributes:t=[],parent:r=null,children:i=[]}={}){super(),this.defaultEventApplied=!1,this.tokenList=new DOMTokenListService_1.DOMTokenListService,this.tag=e,this.attributeList=t.concat([{name:"className",value:""},{name:"id",value:""},{name:"innerHTML",value:""}]),this.propertyAttributes=this.attributeList.map(({name:e})=>e),this.attributeList.forEach(({name:e,value:t})=>{this[e]=t}),i.forEach(e=>{if(!e||"number"!=typeof e.nodeType)throw new TypeError("The children of an element must be nodes.");this.appendChild(e)}),r&&r.appendChild(this)}get tagName(){return this.tag}get nodeType(){return NodeService_1.NodeService.ELEMENT_NODE}get attributes(){return new NamedNodeMapService_1.NamedNodeMapService(this.attributeList.map(({name:e,value:t})=>new AttrService_1.AttrService(e,String(t),this)))}get classList(){return this.tokenList}get className(){return this.tokenList.value}set className(e){this.tokenList.value=e}applyDefaultEvent(){let e=e=>{};if(this.defaultEventApplied)return e;switch(this.tagName){case"button":case"input":/^(submit|image)$/i.test(this.type||"")&&(e=e=>{const t=(0,getParentNodesFromAttribute_1.default)("tagName","form",this);t.length&&t[t.length-1].dispatchEvent(new EventService_1.EventService("submit",{bubbles:!0,cancelable:!0}))},super.setDefaultEvent("click",e),this.defaultEventApplied=!0)}return e}childInserted(e){"function"==typeof e.applyDefaultEvent&&e.applyDefaultEvent()}hasAttribute(e){return this.attributeList.some(({name:t})=>t===e)}setAttribute(e,t){const r=this.attributeList.find(({name:t})=>t===e);r?r.value=t:this.attributeList.push({name:e,value:t}),this.propertyAttributes.indexOf(e)>=0&&(this[e]=t)}getAttribute(e){const t=this.attributeList.find(({name:t})=>t===e);return t?t.value:null}removeAttribute(e){const t=this.attributeList.findIndex(({name:t})=>t===e);t>=0&&this.attributeList.splice(t,1)}}exports.ElementService=ElementService;
1
+ "use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/esnext.iterator.some.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ElementService=void 0;const createEvent_1=__importDefault(require("../factories/createEvent")),NodeService_1=require("./NodeService"),AttrService_1=require("./AttrService"),DOMTokenListService_1=require("./DOMTokenListService"),NamedNodeMapService_1=require("./NamedNodeMapService"),getParentNodesFromAttribute_1=__importDefault(require("../functions/getParentNodesFromAttribute")),cloneObject_1=__importDefault(require("si-funciona/dist/helpers/objects/cloneObject")),isEqual_1=__importDefault(require("si-funciona/dist/helpers/objects/isEqual"));class ElementService extends NodeService_1.NodeService{constructor({tagName:e="",attributes:t=[],parent:r=null,children:i=[]}={}){super(),this.defaultEventApplied=!1,this.tokenList=new DOMTokenListService_1.DOMTokenListService,this.tag=e,this.attributeList=t.concat([{name:"className",value:""},{name:"id",value:""},{name:"innerHTML",value:""}]),this.propertyAttributes=this.attributeList.map(({name:e})=>e),this.attributeList.forEach(({name:e,value:t})=>{this[e]=t}),i.forEach(e=>{if(!e||"number"!=typeof e.nodeType)throw new TypeError("The children of an element must be nodes.");this.appendChild(e)}),r&&r.appendChild(this)}currentAttributes(){return this.attributeList.map(({name:e,value:t})=>({name:e,value:this.propertyAttributes.indexOf(e)>=0?this[e]:t}))}get nodeName(){return this.tag}cloneShallow(){const e=new this.constructor({tagName:this.tag});return e.attributeList.length=0,this.currentAttributes().forEach(({name:t,value:r})=>{const i="object"==typeof r&&null!==r?(0,cloneObject_1.default)(r):r;e.attributeList.push({name:t,value:i}),e.propertyAttributes.indexOf(t)>=0&&(e[t]=i)}),e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){const t=this.currentAttributes(),r=e.currentAttributes();return this.nodeName===e.nodeName&&t.length===r.length&&t.every(({name:e,value:t})=>{const i=r.find(t=>t.name===e);return void 0!==i&&(0,isEqual_1.default)(t,i.value)})}get tagName(){return this.tag}get nodeType(){return NodeService_1.NodeService.ELEMENT_NODE}get attributes(){return new NamedNodeMapService_1.NamedNodeMapService(this.currentAttributes().map(({name:e,value:t})=>new AttrService_1.AttrService(e,String(t),this)))}get classList(){return this.tokenList}get className(){return this.tokenList.value}set className(e){this.tokenList.value=e}applyDefaultEvent(){let e=e=>{};if(this.defaultEventApplied)return e;switch(this.tagName){case"button":case"input":e=e=>{const t=String(this.getAttribute("type")||this.type||"").toLowerCase(),r="button"===this.tagName?"button"!==t&&"reset"!==t:/^(submit|image)$/.test(t),i=(0,getParentNodesFromAttribute_1.default)("tagName","form",this);r&&i.length&&!this.hasAttribute("disabled")&&i[i.length-1].dispatchEvent((0,createEvent_1.default)("submit",{},{browser:!0,trusted:e.isTrusted}))},super.setDefaultEvent("click",e),this.defaultEventApplied=!0}return e}childInserted(e){"function"==typeof e.applyDefaultEvent&&e.applyDefaultEvent()}hasAttribute(e){return this.attributeList.some(({name:t})=>t===e)}setAttribute(e,t){const r=this.attributeList.find(({name:t})=>t===e);r?r.value=t:this.attributeList.push({name:e,value:t}),this.propertyAttributes.indexOf(e)>=0&&(this[e]=t)}getAttribute(e){const t=this.currentAttributes().find(({name:t})=>t===e);return t?t.value:null}removeAttribute(e){const t=this.attributeList.findIndex(({name:t})=>t===e);t>=0&&this.attributeList.splice(t,1)}}exports.ElementService=ElementService;
@@ -15,6 +15,8 @@ export type EventInner = {
15
15
  target: PseudoEventTarget;
16
16
  immediatePropagationStopped: boolean;
17
17
  propagationStopped: boolean;
18
+ /** True for an event which the browser created for a user action, an event which a script created is not trusted. */
19
+ trusted: boolean;
18
20
  /** True while the event is being dispatched. */
19
21
  dispatching: boolean;
20
22
  /** True while a passive listener is running, in which preventDefault does nothing. */
@@ -65,7 +65,7 @@ class EventService {
65
65
  target: null,
66
66
  timeStamp: Math.floor(Date.now() / 1000),
67
67
  type: '',
68
- isTrusted: true,
68
+ isTrusted: false,
69
69
  dispatching: false,
70
70
  inPassiveListener: false,
71
71
  path: []
@@ -149,6 +149,12 @@ class EventService {
149
149
  get propagationStopped () {
150
150
  return self.properties.propagationStopped
151
151
  },
152
+ get trusted () {
153
+ return self.properties.isTrusted
154
+ },
155
+ set trusted (trusted) {
156
+ self.properties.isTrusted = trusted
157
+ },
152
158
  get dispatching () {
153
159
  return self.properties.dispatching
154
160
  },
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventService=void 0;class EventService{constructor(e="",{bubbles:t=!1,cancelable:r=!1,composed:i=!1}={}){this.properties={bubbles:!1,cancelable:!1,composed:!1,currentTarget:null,defaultPrevented:!1,immediatePropagationStopped:!1,propagationStopped:!1,eventPhase:0,target:null,timeStamp:Math.floor(Date.now()/1e3),type:"",isTrusted:!0,dispatching:!1,inPassiveListener:!1,path:[]},this.setReadOnlyProperties({type:e,bubbles:t,cancelable:r,composed:i})}get bubbles(){return this.properties.bubbles}get cancelable(){return this.properties.cancelable}get composed(){return this.properties.composed}get currentTarget(){return this.properties.currentTarget}get defaultPrevented(){return this.properties.defaultPrevented}get eventPhase(){return this.properties.eventPhase}get isTrusted(){return this.properties.isTrusted}get target(){return this.properties.target}get timeStamp(){return this.properties.timeStamp}get type(){return this.properties.type}get inner(){const e=this;return{get currentTarget(){return e.properties.currentTarget},set currentTarget(t){e.properties.currentTarget=t},get eventPhase(){return e.properties.eventPhase},set eventPhase(t){e.properties.eventPhase=t},get target(){return e.properties.target},set target(t){e.properties.target=t},get immediatePropagationStopped(){return e.properties.immediatePropagationStopped},get propagationStopped(){return e.properties.propagationStopped},get dispatching(){return e.properties.dispatching},set dispatching(t){e.properties.dispatching=t},get inPassiveListener(){return e.properties.inPassiveListener},set inPassiveListener(t){e.properties.inPassiveListener=t},get path(){return e.properties.path},set path(t){e.properties.path=t},finishDispatch(){e.setReadOnlyProperties({currentTarget:null,eventPhase:EventService.NONE,path:[],dispatching:!1,inPassiveListener:!1,propagationStopped:!1,immediatePropagationStopped:!1})}}}composedPath(){return this.properties.dispatching?this.properties.path.slice():[]}preventDefault(){return this.cancelable&&!this.properties.inPassiveListener&&this.setReadOnlyProperties({defaultPrevented:!0}),null}stopImmediatePropagation(){return this.setReadOnlyProperties({immediatePropagationStopped:!0}),null}stopPropagation(){return this.setReadOnlyProperties({propagationStopped:!0}),null}setReadOnlyProperties(e={}){return this.properties=Object.assign({},this.properties,e),this}}exports.EventService=EventService,EventService.NONE=0,EventService.CAPTURING_PHASE=1,EventService.AT_TARGET=2,EventService.BUBBLING_PHASE=3;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventService=void 0;class EventService{constructor(e="",{bubbles:t=!1,cancelable:r=!1,composed:s=!1}={}){this.properties={bubbles:!1,cancelable:!1,composed:!1,currentTarget:null,defaultPrevented:!1,immediatePropagationStopped:!1,propagationStopped:!1,eventPhase:0,target:null,timeStamp:Math.floor(Date.now()/1e3),type:"",isTrusted:!1,dispatching:!1,inPassiveListener:!1,path:[]},this.setReadOnlyProperties({type:e,bubbles:t,cancelable:r,composed:s})}get bubbles(){return this.properties.bubbles}get cancelable(){return this.properties.cancelable}get composed(){return this.properties.composed}get currentTarget(){return this.properties.currentTarget}get defaultPrevented(){return this.properties.defaultPrevented}get eventPhase(){return this.properties.eventPhase}get isTrusted(){return this.properties.isTrusted}get target(){return this.properties.target}get timeStamp(){return this.properties.timeStamp}get type(){return this.properties.type}get inner(){const e=this;return{get currentTarget(){return e.properties.currentTarget},set currentTarget(t){e.properties.currentTarget=t},get eventPhase(){return e.properties.eventPhase},set eventPhase(t){e.properties.eventPhase=t},get target(){return e.properties.target},set target(t){e.properties.target=t},get immediatePropagationStopped(){return e.properties.immediatePropagationStopped},get propagationStopped(){return e.properties.propagationStopped},get trusted(){return e.properties.isTrusted},set trusted(t){e.properties.isTrusted=t},get dispatching(){return e.properties.dispatching},set dispatching(t){e.properties.dispatching=t},get inPassiveListener(){return e.properties.inPassiveListener},set inPassiveListener(t){e.properties.inPassiveListener=t},get path(){return e.properties.path},set path(t){e.properties.path=t},finishDispatch(){e.setReadOnlyProperties({currentTarget:null,eventPhase:EventService.NONE,path:[],dispatching:!1,inPassiveListener:!1,propagationStopped:!1,immediatePropagationStopped:!1})}}}composedPath(){return this.properties.dispatching?this.properties.path.slice():[]}preventDefault(){return this.cancelable&&!this.properties.inPassiveListener&&this.setReadOnlyProperties({defaultPrevented:!0}),null}stopImmediatePropagation(){return this.setReadOnlyProperties({immediatePropagationStopped:!0}),null}stopPropagation(){return this.setReadOnlyProperties({propagationStopped:!0}),null}setReadOnlyProperties(e={}){return this.properties=Object.assign({},this.properties,e),this}}exports.EventService=EventService,EventService.NONE=0,EventService.CAPTURING_PHASE=1,EventService.AT_TARGET=2,EventService.BUBBLING_PHASE=3;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file Substitute for the DOM FocusEvent Class.
3
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
4
+ * @version 1.0.0
5
+ */
6
+ import { UIEventInit, UIEventService } from './UIEventService';
7
+ import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
8
+ /**
9
+ * The options for creating a focus event, on top of the ones every UI event has.
10
+ * @typedef {Object} FocusEventInit
11
+ * @property {PseudoEventTarget|null} [relatedTarget=null] The other target involved (the one losing or gaining the focus)
12
+ */
13
+ export type FocusEventInit = UIEventInit & {
14
+ relatedTarget?: PseudoEventTarget | null;
15
+ };
16
+ /**
17
+ * Simulate the behaviour of the FocusEvent Class when there is no DOM available.
18
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
19
+ * @class
20
+ * @augments UIEventService
21
+ * @property {PseudoEventTarget|null} relatedTarget
22
+ */
23
+ export declare class FocusEventService extends UIEventService {
24
+ private readonly related;
25
+ /**
26
+ * @param {string} [typeArg=''] The type of the event
27
+ * @param {FocusEventInit} [init={}] The options for the event
28
+ * @constructor
29
+ */
30
+ constructor(typeArg?: string, init?: FocusEventInit);
31
+ get relatedTarget(): PseudoEventTarget | null;
32
+ }
@@ -0,0 +1,35 @@
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.FocusEventService = void 0
7
+ /**
8
+ * @file Substitute for the DOM FocusEvent Class.
9
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
10
+ * @version 1.0.0
11
+ */
12
+ const UIEventService_1 = require('./UIEventService')
13
+ /**
14
+ * Simulate the behaviour of the FocusEvent Class when there is no DOM available.
15
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
16
+ * @class
17
+ * @augments UIEventService
18
+ * @property {PseudoEventTarget|null} relatedTarget
19
+ */
20
+ class FocusEventService extends UIEventService_1.UIEventService {
21
+ /**
22
+ * @param {string} [typeArg=''] The type of the event
23
+ * @param {FocusEventInit} [init={}] The options for the event
24
+ * @constructor
25
+ */
26
+ constructor (typeArg = '', init = {}) {
27
+ super(typeArg, init)
28
+ this.related = init.relatedTarget || null
29
+ }
30
+
31
+ get relatedTarget () {
32
+ return this.related
33
+ }
34
+ }
35
+ exports.FocusEventService = FocusEventService
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FocusEventService=void 0;const UIEventService_1=require("./UIEventService");class FocusEventService extends UIEventService_1.UIEventService{constructor(e="",t={}){super(e,t),this.related=t.relatedTarget||null}get relatedTarget(){return this.related}}exports.FocusEventService=FocusEventService;
@@ -34,4 +34,24 @@ export declare class HTMLElementService extends ElementService implements Partia
34
34
  parent?: PseudoNode | null;
35
35
  children?: Array<any>;
36
36
  });
37
+ /**
38
+ * Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
39
+ * @returns {boolean}
40
+ */
41
+ get canFocus(): boolean;
42
+ /**
43
+ * Click the element: a click event is sent to it, which bubbles and can be cancelled, like one from a user but a
44
+ * script made it (so it is not trusted). A disabled element does nothing.
45
+ */
46
+ click(): void;
47
+ /**
48
+ * Give the element the focus. The element which had it gets blur then focusout, and this one gets focus then
49
+ * focusin (blur and focus do not bubble, focusin and focusout do). Nothing happens when the element cannot have the
50
+ * focus or already has it.
51
+ */
52
+ focus(): void;
53
+ /**
54
+ * Take the focus away from the element, when it has it: it gets blur then focusout.
55
+ */
56
+ blur(): void;
37
57
  }